mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
Fix #45892. Null check
This commit is contained in:
parent
234d100603
commit
ca666da08b
|
@ -592,7 +592,13 @@ export class PieceTreeBase {
|
||||||
const searcher = new Searcher(searchData.wordSeparators, searchData.regex);
|
const searcher = new Searcher(searchData.wordSeparators, searchData.regex);
|
||||||
|
|
||||||
let startPostion = this.nodeAt2(searchRange.startLineNumber, searchRange.startColumn);
|
let startPostion = this.nodeAt2(searchRange.startLineNumber, searchRange.startColumn);
|
||||||
|
if (startPostion === null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let endPosition = this.nodeAt2(searchRange.endLineNumber, searchRange.endColumn);
|
let endPosition = this.nodeAt2(searchRange.endLineNumber, searchRange.endColumn);
|
||||||
|
if (endPosition === null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
let start = this.positionInBuffer(startPostion.node, startPostion.remainder);
|
let start = this.positionInBuffer(startPostion.node, startPostion.remainder);
|
||||||
let end = this.positionInBuffer(endPosition.node, endPosition.remainder);
|
let end = this.positionInBuffer(endPosition.node, endPosition.remainder);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ import { SENTINEL, NodeColor, TreeNode } from 'vs/editor/common/model/pieceTreeT
|
||||||
import { PieceTreeTextBuffer } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer';
|
import { PieceTreeTextBuffer } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer';
|
||||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||||
import { ITextSnapshot } from 'vs/platform/files/common/files';
|
import { ITextSnapshot } from 'vs/platform/files/common/files';
|
||||||
|
import { SearchData } from 'vs/editor/common/model/textModelSearch';
|
||||||
|
import { WordCharacterClassifier } from 'vs/editor/common/controller/wordCharacterClassifier';
|
||||||
|
|
||||||
const alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n';
|
const alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n';
|
||||||
|
|
||||||
|
@ -1776,4 +1778,13 @@ suite('snapshot', () => {
|
||||||
|
|
||||||
assert.notEqual(model.getLinesContent().join('\n'), getValueInSnapshot(snapshot));
|
assert.notEqual(model.getLinesContent().join('\n'), getValueInSnapshot(snapshot));
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
suite('chunk based search', () => {
|
||||||
|
test('#45892. For some cases, the buffer is empty but we still try to search', () => {
|
||||||
|
let pieceTree = createTextBuffer(['']);
|
||||||
|
pieceTree.delete(0, 1);
|
||||||
|
let ret = pieceTree.findMatchesLineByLine(new Range(1, 1, 1, 1), new SearchData(/abc/, new WordCharacterClassifier(',./'), 'abc'), true, 1000);
|
||||||
|
assert.equal(ret.length, 0);
|
||||||
|
});
|
||||||
});
|
});
|
Loading…
Reference in a new issue