mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-12 19:39:20 -05:00
don't reset textOffset when column is within first search window, fixes https://github.com/microsoft/vscode/issues/108892
also restore time budget check
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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(''), [
|
||||
` <p><span xml:lang="en">Sheldon</span>, soprannominato "<span xml:lang="en">Shelly</span> dalla madre e dalla sorella, è nato a <span xml:lang="en">Galveston</span>, in <span xml:lang="en">Texas</span>, 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 <span xml:lang="en">North Los Robles Avenue</span> di <span xml:lang="en">Pasadena</span>, per poi trasferirsi nell'appartamento di <span xml:lang="en">Penny</span> con <span xml:lang="en">Amy</span> 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 <span xml:lang="en">Sheldon</span>; tuttavia la donna sembra essere l'unica persona in grado di comandarlo a bacchetta.</p>`
|
||||
], '\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 {
|
||||
|
||||
Reference in New Issue
Block a user