This commit is contained in:
Andrii Dieiev 2021-11-26 20:28:07 +01:00 committed by GitHub
commit a55f49182a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -533,7 +533,8 @@ export class Searcher {
let m: RegExpExecArray | null;
do {
if (this._prevMatchStartIndex + this._prevMatchLength === textLength) {
const previousMatchEnd = this._prevMatchStartIndex + this._prevMatchLength;
if (previousMatchEnd === textLength) {
// Reached the end of the line
return null;
}
@ -562,6 +563,11 @@ export class Searcher {
this._prevMatchStartIndex = matchStartIndex;
this._prevMatchLength = matchLength;
// do not return empty matches at he end of previous match
if (matchLength === 0 && matchStartIndex === previousMatchEnd) {
continue;
}
if (!this._wordSeparators || isValidMatch(this._wordSeparators, text, textLength, matchStartIndex, matchLength)) {
return m;
}

View file

@ -757,11 +757,8 @@ suite('TextModelSearch', () => {
let actual = TextModelSearch.findMatches(model, searchParams, model.getFullModelRange(), true, 100);
assert.deepStrictEqual(actual, [
new FindMatch(new Range(1, 1, 1, 3), ['10']),
new FindMatch(new Range(1, 3, 1, 3), ['']),
new FindMatch(new Range(1, 4, 1, 7), ['243']),
new FindMatch(new Range(1, 7, 1, 7), ['']),
new FindMatch(new Range(1, 8, 1, 10), ['30']),
new FindMatch(new Range(1, 10, 1, 10), ['']),
new FindMatch(new Range(1, 11, 1, 13), ['10'])
]);