diff --git a/src/vs/editor/common/model/wordHelper.ts b/src/vs/editor/common/model/wordHelper.ts index e857ddabb53..a1cae550a88 100644 --- a/src/vs/editor/common/model/wordHelper.ts +++ b/src/vs/editor/common/model/wordHelper.ts @@ -68,7 +68,6 @@ export function getWordAtText(column: number, wordDefinition: RegExp, text: stri // but use a sub-string in which a word must occur let start = column - config.maxLen / 2; if (start < 0) { - textOffset += column; start = 0; } else { textOffset += start; @@ -86,7 +85,7 @@ export function getWordAtText(column: number, wordDefinition: RegExp, text: stri for (let i = 1; ; i++) { // check time budget if (Date.now() - t1 >= config.timeBudget) { - // break; + break; } // reset the index at which the regexp should start matching, also know where it diff --git a/src/vs/workbench/test/browser/api/extHostDocumentData.test.ts b/src/vs/workbench/test/browser/api/extHostDocumentData.test.ts index ef2d1c5c0aa..4519c6154fc 100644 --- a/src/vs/workbench/test/browser/api/extHostDocumentData.test.ts +++ b/src/vs/workbench/test/browser/api/extHostDocumentData.test.ts @@ -331,6 +331,21 @@ suite('ExtHostDocumentData', () => { assert.equal(range.start.character, 4); assert.equal(range.end.character, 28); }); + + test('Custom snippet $TM_SELECTED_TEXT not show suggestion #108892', function () { + + data = new ExtHostDocumentData(undefined!, URI.file(''), [ + `

Sheldon, soprannominato "Shelly dalla madre e dalla sorella, è nato a Galveston, in Texas, il 26 febbraio 1980 in un supermercato. È stato un bambino prodigio, come testimoniato dal suo quoziente d'intelligenza (187, di molto superiore alla norma) e dalla sua rapida carriera scolastica: si è diplomato all'eta di 11 anni approdando alla stessa età alla formazione universitaria e all'età di 16 anni ha ottenuto il suo primo dottorato di ricerca. All'inizio della serie e per gran parte di essa vive con il coinquilino Leonard nell'appartamento 4A al 2311 North Los Robles Avenue di Pasadena, per poi trasferirsi nell'appartamento di Penny con Amy nella decima stagione. Come più volte afferma lui stesso possiede una memoria eidetica e un orecchio assoluto. È stato educato da una madre estremamente religiosa e, in più occasioni, questo aspetto contrasta con il rigore scientifico di Sheldon; tuttavia la donna sembra essere l'unica persona in grado di comandarlo a bacchetta.

` + ], '\n', 1, 'text', false); + + const pos = new Position(0, 55); + const range = data.document.getWordRangeAtPosition(pos)!; + assert.equal(range.start.line, 0); + assert.equal(range.end.line, 0); + assert.equal(range.start.character, 47); + assert.equal(range.end.character, 61); + assert.equal(data.document.getText(range), 'soprannominato'); + }); }); enum AssertDocumentLineMappingDirection {