提交 b05d8f3a 编写于 作者: J Johannes Rieken
上级 73b5307a
......@@ -93,13 +93,15 @@ export function getWordAtText(column: number, wordDefinition: RegExp, text: stri
// should stop so that subsequent search don't repeat previous searches
const regexIndex = pos - config.windowSize * i;
wordDefinition.lastIndex = Math.max(0, regexIndex);
match = _findRegexMatchEnclosingPosition(wordDefinition, text, pos, prevRegexIndex);
const thisMatch = _findRegexMatchEnclosingPosition(wordDefinition, text, pos, prevRegexIndex);
// stop: found something
if (match) {
if (!thisMatch && match) {
// stop: we have something
break;
}
match = thisMatch;
// stop: searched at start
if (regexIndex <= 0) {
break;
......@@ -111,7 +113,7 @@ export function getWordAtText(column: number, wordDefinition: RegExp, text: stri
let result = {
word: match[0],
startColumn: textOffset + 1 + match.index!,
endColumn: textOffset + 1 + wordDefinition.lastIndex
endColumn: textOffset + 1 + match.index! + match[0].length
};
wordDefinition.lastIndex = 0;
return result;
......
......@@ -315,6 +315,22 @@ suite('ExtHostDocumentData', () => {
assert.ok(range.contains(pos));
assert.equal(data.document.getText(range), 'TaskDefinition');
});
test('Rename popup sometimes populates with text on the left side omitted #96013', function () {
const regex = /(-?\d*\.\d\w*)|([^\`\~\!\@\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;
const line = 'int abcdefhijklmnopqwvrstxyz;';
data = new ExtHostDocumentData(undefined!, URI.file(''), [
line
], '\n', 'text', 1, false);
let range = data.document.getWordRangeAtPosition(new Position(0, 27), regex)!;
assert.equal(range.start.line, 0);
assert.equal(range.end.line, 0);
assert.equal(range.start.character, 4);
assert.equal(range.end.character, 28);
});
});
enum AssertDocumentLineMappingDirection {
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册