Merge VS Code 1.31.1 (#4283)

This commit is contained in:
Matt Irvine
2019-03-15 13:09:45 -07:00
committed by GitHub
parent 7d31575149
commit 86bac90001
1716 changed files with 53308 additions and 48375 deletions

View File

@@ -8,9 +8,9 @@ import { PieceTreeTextBufferBuilder } from 'vs/editor/common/model/pieceTreeText
export function doBenchmark<T>(id: string, ts: T[], fn: (t: T) => void) {
let columns: string[] = [id];
for (let i = 0; i < ts.length; i++) {
for (const t of ts) {
let start = process.hrtime();
fn(ts[i]);
fn(t);
let diff = process.hrtime(start);
columns.push(`${(diff[0] * 1000 + diff[1] / 1000000).toFixed(3)} ms`);
}
@@ -52,11 +52,10 @@ export class BenchmarkSuite {
run() {
console.log(`|${this.name}\t|line buffer\t|piece table\t|edcore\t`);
console.log('|---|---|---|---|');
for (let i = 0; i < this.benchmarks.length; i++) {
let benchmark = this.benchmarks[i];
for (const benchmark of this.benchmarks) {
let columns: string[] = [benchmark.name];
[new PieceTreeTextBufferBuilder()].forEach((builder: ITextBufferBuilder) => {
let timeDiffTotal = 0.0;
let timeDiffTotal = 0;
for (let j = 0; j < this.iterations; j++) {
let factory = benchmark.buildBuffer(builder);
let buffer = factory.create(DefaultEndOfLine.LF);

View File

@@ -53,8 +53,8 @@ for (let fileSize of fileSizes) {
},
fn: (textBuffer) => {
// for line model, this loop doesn't reflect the real situation.
for (let k = 0; k < edits.length; k++) {
textBuffer.applyEdits([edits[k]], false);
for (const edit of edits) {
textBuffer.applyEdits([edit], false);
}
}
});
@@ -66,8 +66,8 @@ for (let fileSize of fileSizes) {
return textBufferBuilder.finish();
},
preCycle: (textBuffer) => {
for (let k = 0; k < edits.length; k++) {
textBuffer.applyEdits([edits[k]], false);
for (const edit of edits) {
textBuffer.applyEdits([edit], false);
}
return textBuffer;
},
@@ -90,8 +90,8 @@ for (let fileSize of fileSizes) {
return textBufferBuilder.finish();
},
preCycle: (textBuffer) => {
for (let k = 0; k < edits.length; k++) {
textBuffer.applyEdits([edits[k]], false);
for (const edit of edits) {
textBuffer.applyEdits([edit], false);
}
return textBuffer;
},
@@ -120,8 +120,8 @@ for (let fileSize of fileSizes) {
return textBufferBuilder.finish();
},
preCycle: (textBuffer) => {
for (let k = 0; k < edits.length; k++) {
textBuffer.applyEdits([edits[k]], false);
for (const edit of edits) {
textBuffer.applyEdits([edit], false);
}
return textBuffer;
},

View File

@@ -1044,7 +1044,7 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
let model = createEditableTextModelFromString('Hello\nWorld!');
assert.equal(model.getEOL(), '\n');
let mirrorModel2 = new MirrorTextModel(null, model.getLinesContent(), model.getEOL(), model.getVersionId());
let mirrorModel2 = new MirrorTextModel(null!, model.getLinesContent(), model.getEOL(), model.getVersionId());
let mirrorModel2PrevVersionId = model.getVersionId();
model.onDidChangeContent((e: IModelContentChangedEvent) => {

View File

@@ -224,12 +224,12 @@ class TestModel {
let offsetToPosition = TestModel._generateOffsetToPosition(this.initialContent);
this.edits = [];
for (let i = 0; i < edits.length; i++) {
let startPosition = offsetToPosition[edits[i].offset];
let endPosition = offsetToPosition[edits[i].offset + edits[i].length];
for (const edit of edits) {
let startPosition = offsetToPosition[edit.offset];
let endPosition = offsetToPosition[edit.offset + edit.length];
this.edits.push({
range: new Range(startPosition.lineNumber, startPosition.column, endPosition.lineNumber, endPosition.column),
text: edits[i].text
text: edit.text
});
}
@@ -252,7 +252,7 @@ class TestModel {
r.push('\t],');
r.push('\t[');
r = r.concat(this.edits.map((i) => {
let text = `['` + i.text.split('\n').join(`', '`) + `']`;
let text = `['` + i.text!.split('\n').join(`', '`) + `']`;
return `\t\teditOp(${i.range.startLineNumber}, ${i.range.startColumn}, ${i.range.endLineNumber}, ${i.range.endColumn}, ${text}),`;
}));
r.push('\t],');

View File

@@ -74,8 +74,8 @@ suite('IntervalTree', () => {
private _oracle: Oracle = new Oracle();
private _tree: IntervalTree = new IntervalTree();
private _lastNodeId = -1;
private _treeNodes: IntervalNode[] = [];
private _oracleNodes: Interval[] = [];
private _treeNodes: Array<IntervalNode | null> = [];
private _oracleNodes: Array<Interval | null> = [];
public acceptOp(op: IOperation): void {
@@ -84,28 +84,28 @@ suite('IntervalTree', () => {
console.log(`insert: {${JSON.stringify(new Interval(op.begin, op.end))}}`);
}
let nodeId = (++this._lastNodeId);
this._treeNodes[nodeId] = new IntervalNode(null, op.begin, op.end);
this._tree.insert(this._treeNodes[nodeId]);
this._treeNodes[nodeId] = new IntervalNode(null!, op.begin, op.end);
this._tree.insert(this._treeNodes[nodeId]!);
this._oracleNodes[nodeId] = this._oracle.insert(new Interval(op.begin, op.end));
} else if (op.type === 'delete') {
if (PRINT_TREE) {
console.log(`delete: {${JSON.stringify(this._oracleNodes[op.id])}}`);
}
this._tree.delete(this._treeNodes[op.id]);
this._oracle.delete(this._oracleNodes[op.id]);
this._tree.delete(this._treeNodes[op.id]!);
this._oracle.delete(this._oracleNodes[op.id]!);
this._treeNodes[op.id] = null;
this._oracleNodes[op.id] = null;
} else if (op.type === 'change') {
this._tree.delete(this._treeNodes[op.id]);
this._treeNodes[op.id].reset(0, op.begin, op.end, null);
this._tree.insert(this._treeNodes[op.id]);
this._tree.delete(this._treeNodes[op.id]!);
this._treeNodes[op.id]!.reset(0, op.begin, op.end, null!);
this._tree.insert(this._treeNodes[op.id]!);
this._oracle.delete(this._oracleNodes[op.id]);
this._oracleNodes[op.id].start = op.begin;
this._oracleNodes[op.id].end = op.end;
this._oracle.insert(this._oracleNodes[op.id]);
this._oracle.delete(this._oracleNodes[op.id]!);
this._oracleNodes[op.id]!.start = op.begin;
this._oracleNodes[op.id]!.end = op.end;
this._oracle.insert(this._oracleNodes[op.id]!);
} else {
let actualNodes = this._tree.intervalSearch(op.begin, op.end, 0, false, 0);
@@ -489,7 +489,7 @@ suite('IntervalTree', () => {
[19, 20]
];
data.forEach((int) => {
let node = new IntervalNode(null, int[0], int[1]);
let node = new IntervalNode(null!, int[0], int[1]);
r.insert(node);
});
return r;

View File

@@ -11,7 +11,7 @@ import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
suite('PieceTreeTextBuffer._getInverseEdits', () => {
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, text: string[]): IValidatedEditOperation {
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, text: string[] | null): IValidatedEditOperation {
return {
sortIndex: 0,
identifier: null,
@@ -262,7 +262,7 @@ suite('PieceTreeTextBuffer._getInverseEdits', () => {
suite('PieceTreeTextBuffer._toSingleEditOperation', () => {
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, rangeOffset: number, rangeLength: number, text: string[]): IValidatedEditOperation {
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, rangeOffset: number, rangeLength: number, text: string[] | null): IValidatedEditOperation {
return {
sortIndex: 0,
identifier: null,

View File

@@ -33,8 +33,8 @@ export function getRandomString(minLength: number, maxLength: number): string {
export function generateRandomEdits(chunks: string[], editCnt: number): IIdentifiedSingleEditOperation[] {
let lines: string[] = [];
for (let i = 0; i < chunks.length; i++) {
let newLines = chunks[i].split(/\r\n|\r|\n/);
for (const chunk of chunks) {
let newLines = chunk.split(/\r\n|\r|\n/);
if (lines.length === 0) {
lines.push(...newLines);
} else {
@@ -50,7 +50,7 @@ export function generateRandomEdits(chunks: string[], editCnt: number): IIdentif
let startColumn = getRandomInt(1, Math.max(lines[line - 1].length, 1));
let endColumn = getRandomInt(startColumn, Math.max(lines[line - 1].length, startColumn));
let text: string = '';
if (Math.random() < .5) {
if (Math.random() < 0.5) {
text = getRandomString(5, 10);
}
@@ -66,8 +66,8 @@ export function generateRandomEdits(chunks: string[], editCnt: number): IIdentif
export function generateSequentialInserts(chunks: string[], editCnt: number): IIdentifiedSingleEditOperation[] {
let lines: string[] = [];
for (let i = 0; i < chunks.length; i++) {
let newLines = chunks[i].split(/\r\n|\r|\n/);
for (const chunk of chunks) {
let newLines = chunk.split(/\r\n|\r|\n/);
if (lines.length === 0) {
lines.push(...newLines);
} else {
@@ -82,7 +82,7 @@ export function generateSequentialInserts(chunks: string[], editCnt: number): II
let line = lines.length;
let column = lines[line - 1].length + 1;
let text: string = '';
if (Math.random() < .5) {
if (Math.random() < 0.5) {
text = '\n';
lines.push('');
} else {
@@ -101,8 +101,8 @@ export function generateSequentialInserts(chunks: string[], editCnt: number): II
export function generateRandomReplaces(chunks: string[], editCnt: number, searchStringLen: number, replaceStringLen: number): IIdentifiedSingleEditOperation[] {
let lines: string[] = [];
for (let i = 0; i < chunks.length; i++) {
let newLines = chunks[i].split(/\r\n|\r|\n/);
for (const chunk of chunks) {
let newLines = chunk.split(/\r\n|\r|\n/);
if (lines.length === 0) {
lines.push(...newLines);
} else {

View File

@@ -74,7 +74,8 @@ class TestToken {
this.color = color;
}
public static toTokens(tokens: TestToken[]): Uint32Array {
public static toTokens(tokens: TestToken[]): Uint32Array;
public static toTokens(tokens: TestToken[] | null): Uint32Array | null {
if (tokens === null) {
return null;
}
@@ -659,7 +660,7 @@ suite('ModelLinesTokens', () => {
test('updates tokens on insertion 10', () => {
testLineEditTokens(
'',
null,
null!,
[{
startColumn: 1,
endColumn: 1,

View File

@@ -26,15 +26,15 @@ suite('Editor Model - Model Modes 1', () => {
const tokenizationSupport: modes.ITokenizationSupport = {
getInitialState: () => NULL_STATE,
tokenize: undefined,
tokenize: undefined!,
tokenize2: (line: string, state: modes.IState): TokenizationResult2 => {
calledFor.push(line.charAt(0));
return new TokenizationResult2(null, state);
return new TokenizationResult2(null!, state);
}
};
let thisModel: TextModel | null = null;
let languageRegistration: IDisposable | null = null;
let thisModel: TextModel;
let languageRegistration: IDisposable;
setup(() => {
const TEXT =
@@ -51,9 +51,7 @@ suite('Editor Model - Model Modes 1', () => {
teardown(() => {
thisModel.dispose();
thisModel = null;
languageRegistration.dispose();
languageRegistration = null;
calledFor = [];
});
@@ -174,10 +172,10 @@ suite('Editor Model - Model Modes 2', () => {
const tokenizationSupport: modes.ITokenizationSupport = {
getInitialState: () => new ModelState2(''),
tokenize: undefined,
tokenize: undefined!,
tokenize2: (line: string, state: modes.IState): TokenizationResult2 => {
(<ModelState2>state).prevLineContent = line;
return new TokenizationResult2(null, state);
return new TokenizationResult2(null!, state);
}
};
@@ -198,13 +196,13 @@ suite('Editor Model - Model Modes 2', () => {
function statesEqual(model: TextModel, states: string[]): void {
let i, len = states.length - 1;
for (i = 0; i < len; i++) {
stateEqual(model._tokens._getState(i), states[i]);
stateEqual(model._tokens._getState(i)!, states[i]);
}
stateEqual((<any>model)._tokens._lastState, states[len]);
}
let thisModel: TextModel | null = null;
let languageRegistration: IDisposable | null = null;
let thisModel: TextModel;
let languageRegistration: IDisposable;
setup(() => {
const TEXT =
@@ -220,9 +218,7 @@ suite('Editor Model - Model Modes 2', () => {
teardown(() => {
thisModel.dispose();
thisModel = null;
languageRegistration.dispose();
languageRegistration = null;
});
test('getTokensForInvalidLines one text insert', () => {

View File

@@ -387,7 +387,7 @@ suite('Editor Model - Words', () => {
this._register(TokenizationRegistry.register(this.getLanguageIdentifier().language, {
getInitialState: (): IState => NULL_STATE,
tokenize: undefined,
tokenize: undefined!,
tokenize2: (line: string, state: IState): TokenizationResult2 => {
const tokensArr: number[] = [];
let prevLanguageId: LanguageIdentifier | undefined = undefined;

View File

@@ -14,7 +14,7 @@ import { TextModel } from 'vs/editor/common/model/textModel';
interface ILightWeightDecoration2 {
range: Range;
className: string;
className: string | null | undefined;
}
function modelHasDecorations(model: TextModel, decorations: ILightWeightDecoration2[]) {
@@ -46,11 +46,11 @@ function addDecoration(model: TextModel, startLineNumber: number, startColumn: n
return changeAccessor.addDecoration(new Range(startLineNumber, startColumn, endLineNumber, endColumn), {
className: className
});
});
})!;
}
function lineHasDecorations(model: TextModel, lineNumber: number, decorations: { start: number; end: number; className: string; }[]) {
let lineDecorations: Array<{ start: number; end: number; className: string; }> = [];
let lineDecorations: Array<{ start: number; end: number; className: string | null | undefined; }> = [];
let decs = model.getLineDecorations(lineNumber);
for (let i = 0, len = decs.length; i < len; i++) {
lineDecorations.push({
@@ -97,7 +97,6 @@ suite('Editor Model - Model Decorations', () => {
teardown(() => {
thisModel.dispose();
thisModel = null;
});
test('single character decoration', () => {
@@ -1141,8 +1140,8 @@ suite('deltaDecorations', () => {
function readModelDecorations(model: TextModel, ids: string[]): ILightWeightDecoration[] {
return ids.map((id) => {
return {
range: model.getDecorationRange(id),
id: model.getDecorationOptions(id).className
range: model.getDecorationRange(id)!,
id: model.getDecorationOptions(id)!.className!
};
});
}
@@ -1294,7 +1293,7 @@ suite('deltaDecorations', () => {
let actualDecoration = model.getDecorationOptions(ids[0]);
assert.deepEqual(actualDecoration.hoverMessage, { value: 'hello2' });
assert.deepEqual(actualDecoration!.hoverMessage, { value: 'hello2' });
model.dispose();
});
@@ -1318,7 +1317,7 @@ suite('deltaDecorations', () => {
);
});
model.changeDecorations((changeAccessor) => {
changeAccessor.removeDecoration(trackedRangeId);
changeAccessor.removeDecoration(trackedRangeId!);
});
let ids = model.deltaDecorations([], [

View File

@@ -28,7 +28,6 @@ suite('Editor Model - Model Edit Operation', () => {
teardown(() => {
model.dispose();
model = null;
});
function createSingleEditOp(text: string, positionLineNumber: number, positionColumn: number, selectionLineNumber: number = positionLineNumber, selectionColumn: number = positionColumn): IIdentifiedSingleEditOperation {

View File

@@ -106,7 +106,7 @@ function testLineStarts(str: string, pieceTable: PieceTreeBase) {
let prevMatchStartIndex = -1;
let prevMatchLength = 0;
let m: RegExpExecArray;
let m: RegExpExecArray | null;
do {
if (prevMatchStartIndex + prevMatchLength === str.length) {
// Reached the end of the line
@@ -154,8 +154,8 @@ function testLineStarts(str: string, pieceTable: PieceTreeBase) {
function createTextBuffer(val: string[], normalizeEOL: boolean = true): PieceTreeBase {
let bufferBuilder = new PieceTreeTextBufferBuilder();
for (let i = 0; i < val.length; i++) {
bufferBuilder.acceptChunk(val[i]);
for (const chunk of val) {
bufferBuilder.acceptChunk(chunk);
}
let factory = bufferBuilder.finish(normalizeEOL);
return (<PieceTreeTextBuffer>factory.create(DefaultEndOfLine.LF)).getPieceTree();

View File

@@ -26,7 +26,7 @@ function testGuessIndentation(defaultInsertSpaces: boolean, defaultTabSize: numb
assert.equal(r.tabSize, expectedTabSize, msg);
}
function assertGuess(expectedInsertSpaces: boolean, expectedTabSize: number, text: string[], msg?: string): void {
function assertGuess(expectedInsertSpaces: boolean | undefined, expectedTabSize: number | undefined, text: string[], msg?: string): void {
if (typeof expectedInsertSpaces === 'undefined') {
// cannot guess insertSpaces
if (typeof expectedTabSize === 'undefined') {

View File

@@ -17,7 +17,7 @@ suite('TextModelSearch', () => {
const usualWordSeparators = getMapForWordSeparators(USUAL_WORD_SEPARATORS);
function assertFindMatch(actual: FindMatch, expectedRange: Range, expectedMatches: string[] | null = null): void {
function assertFindMatch(actual: FindMatch | null, expectedRange: Range, expectedMatches: string[] | null = null): void {
assert.deepEqual(actual, new FindMatch(expectedRange, expectedMatches));
}
@@ -29,24 +29,24 @@ suite('TextModelSearch', () => {
let startPos = new Position(1, 1);
let match = TextModelSearch.findNextMatch(model, searchParams, startPos, false);
assert.deepEqual(match, expectedMatches[0], `findNextMatch ${startPos}`);
for (let i = 0; i < expectedMatches.length; i++) {
startPos = expectedMatches[i].range.getStartPosition();
for (const expectedMatch of expectedMatches) {
startPos = expectedMatch.range.getStartPosition();
match = TextModelSearch.findNextMatch(model, searchParams, startPos, false);
assert.deepEqual(match, expectedMatches[i], `findNextMatch ${startPos}`);
assert.deepEqual(match, expectedMatch, `findNextMatch ${startPos}`);
}
// test `findPrevMatch`
startPos = new Position(model.getLineCount(), model.getLineMaxColumn(model.getLineCount()));
match = TextModelSearch.findPreviousMatch(model, searchParams, startPos, false);
assert.deepEqual(match, expectedMatches[expectedMatches.length - 1], `findPrevMatch ${startPos}`);
for (let i = 0; i < expectedMatches.length; i++) {
startPos = expectedMatches[i].range.getEndPosition();
for (const expectedMatch of expectedMatches) {
startPos = expectedMatch.range.getEndPosition();
match = TextModelSearch.findPreviousMatch(model, searchParams, startPos, false);
assert.deepEqual(match, expectedMatches[i], `findPrevMatch ${startPos}`);
assert.deepEqual(match, expectedMatch, `findPrevMatch ${startPos}`);
}
}
function assertFindMatches(text: string, searchString: string, isRegex: boolean, matchCase: boolean, wordSeparators: string, _expected: [number, number, number, number][]): void {
function assertFindMatches(text: string, searchString: string, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, _expected: [number, number, number, number][]): void {
let expectedRanges = _expected.map(entry => new Range(entry[0], entry[1], entry[2], entry[3]));
let expectedMatches = expectedRanges.map(entry => new FindMatch(entry, null));
let searchParams = new SearchParams(searchString, isRegex, matchCase, wordSeparators);
@@ -387,16 +387,16 @@ suite('TextModelSearch', () => {
let actual = TextModelSearch.findNextMatch(model, searchParams, new Position(1, 1), false);
assertFindMatch(actual, new Range(1, 1, 1, 5));
actual = TextModelSearch.findNextMatch(model, searchParams, actual.range.getEndPosition(), false);
actual = TextModelSearch.findNextMatch(model, searchParams, actual!.range.getEndPosition(), false);
assertFindMatch(actual, new Range(1, 6, 1, 10));
actual = TextModelSearch.findNextMatch(model, searchParams, new Position(1, 3), false);
assertFindMatch(actual, new Range(1, 6, 1, 10));
actual = TextModelSearch.findNextMatch(model, searchParams, actual.range.getEndPosition(), false);
actual = TextModelSearch.findNextMatch(model, searchParams, actual!.range.getEndPosition(), false);
assertFindMatch(actual, new Range(2, 1, 2, 5));
actual = TextModelSearch.findNextMatch(model, searchParams, actual.range.getEndPosition(), false);
actual = TextModelSearch.findNextMatch(model, searchParams, actual!.range.getEndPosition(), false);
assertFindMatch(actual, new Range(1, 1, 1, 5));
model.dispose();
@@ -410,13 +410,13 @@ suite('TextModelSearch', () => {
let actual = TextModelSearch.findNextMatch(model, searchParams, new Position(1, 1), false);
assertFindMatch(actual, new Range(1, 1, 1, 5));
actual = TextModelSearch.findNextMatch(model, searchParams, actual.range.getEndPosition(), false);
actual = TextModelSearch.findNextMatch(model, searchParams, actual!.range.getEndPosition(), false);
assertFindMatch(actual, new Range(2, 1, 2, 5));
actual = TextModelSearch.findNextMatch(model, searchParams, new Position(1, 3), false);
assertFindMatch(actual, new Range(2, 1, 2, 5));
actual = TextModelSearch.findNextMatch(model, searchParams, actual.range.getEndPosition(), false);
actual = TextModelSearch.findNextMatch(model, searchParams, actual!.range.getEndPosition(), false);
assertFindMatch(actual, new Range(1, 1, 1, 5));
model.dispose();
@@ -430,13 +430,13 @@ suite('TextModelSearch', () => {
let actual = TextModelSearch.findNextMatch(model, searchParams, new Position(1, 1), false);
assertFindMatch(actual, new Range(1, 1, 1, 5));
actual = TextModelSearch.findNextMatch(model, searchParams, actual.range.getEndPosition(), false);
actual = TextModelSearch.findNextMatch(model, searchParams, actual!.range.getEndPosition(), false);
assertFindMatch(actual, new Range(2, 1, 2, 5));
actual = TextModelSearch.findNextMatch(model, searchParams, new Position(1, 3), false);
assertFindMatch(actual, new Range(2, 1, 2, 5));
actual = TextModelSearch.findNextMatch(model, searchParams, actual.range.getEndPosition(), false);
actual = TextModelSearch.findNextMatch(model, searchParams, actual!.range.getEndPosition(), false);
assertFindMatch(actual, new Range(1, 1, 1, 5));
model.dispose();
@@ -450,7 +450,7 @@ suite('TextModelSearch', () => {
let actual = TextModelSearch.findNextMatch(model, searchParams, new Position(1, 1), false);
assertFindMatch(actual, new Range(1, 1, 2, 5));
actual = TextModelSearch.findNextMatch(model, searchParams, actual.range.getEndPosition(), false);
actual = TextModelSearch.findNextMatch(model, searchParams, actual!.range.getEndPosition(), false);
assertFindMatch(actual, new Range(3, 1, 4, 5));
actual = TextModelSearch.findNextMatch(model, searchParams, new Position(2, 1), false);
@@ -470,10 +470,10 @@ suite('TextModelSearch', () => {
actual = TextModelSearch.findNextMatch(model, searchParams, new Position(1, 4), false);
assertFindMatch(actual, new Range(1, 10, 1, 14));
actual = TextModelSearch.findNextMatch(model, searchParams, actual.range.getEndPosition(), false);
actual = TextModelSearch.findNextMatch(model, searchParams, actual!.range.getEndPosition(), false);
assertFindMatch(actual, new Range(2, 5, 2, 9));
actual = TextModelSearch.findNextMatch(model, searchParams, actual.range.getEndPosition(), false);
actual = TextModelSearch.findNextMatch(model, searchParams, actual!.range.getEndPosition(), false);
assertFindMatch(actual, new Range(1, 10, 1, 14));
model.dispose();
@@ -588,26 +588,25 @@ suite('TextModelSearch', () => {
model.dispose();
});
function assertParseSearchResult(searchString: string, isRegex: boolean, matchCase: boolean, wordSeparators: string, expected: SearchData): void {
function assertParseSearchResult(searchString: string, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, expected: SearchData | null): void {
let searchParams = new SearchParams(searchString, isRegex, matchCase, wordSeparators);
let actual = searchParams.parseSearchRequest();
if (expected === null) {
assert.ok(actual === null);
} else {
assert.deepEqual(actual.regex, expected.regex);
assert.deepEqual(actual.simpleSearch, expected.simpleSearch);
assert.deepEqual(actual!.regex, expected.regex);
assert.deepEqual(actual!.simpleSearch, expected.simpleSearch);
if (wordSeparators) {
assert.ok(actual.wordSeparators !== null);
assert.ok(actual!.wordSeparators !== null);
} else {
assert.ok(actual.wordSeparators === null);
assert.ok(actual!.wordSeparators === null);
}
}
}
test('parseSearchRequest invalid', () => {
assertParseSearchResult('', true, true, USUAL_WORD_SEPARATORS, null);
assertParseSearchResult(null, true, true, USUAL_WORD_SEPARATORS, null);
assertParseSearchResult('(', true, false, null, null);
});

View File

@@ -19,7 +19,7 @@ import { ViewLineToken } from 'vs/editor/test/common/core/viewLineToken';
suite('TextModelWithTokens', () => {
function testBrackets(contents: string[], brackets: CharacterPair[]): void {
function toRelaxedFoundBracket(a: IFoundBracket) {
function toRelaxedFoundBracket(a: IFoundBracket | null) {
if (!a) {
return null;
}
@@ -158,7 +158,7 @@ suite('TextModelWithTokens - bracket matching', () => {
}
const languageIdentifier = new LanguageIdentifier('bracketMode1', LanguageId.PlainText);
let registration: IDisposable | null = null;
let registration: IDisposable;
setup(() => {
registration = LanguageConfigurationRegistry.register(languageIdentifier, {
@@ -172,7 +172,6 @@ suite('TextModelWithTokens - bracket matching', () => {
teardown(() => {
registration.dispose();
registration = null;
});
test('bracket matching 1', () => {
@@ -293,7 +292,7 @@ suite('TextModelWithTokens regression tests', () => {
const tokenizationSupport: ITokenizationSupport = {
getInitialState: () => NULL_STATE,
tokenize: undefined,
tokenize: undefined!,
tokenize2: (line, state) => {
let myId = ++_tokenId;
let tokens = new Uint32Array(2);
@@ -397,7 +396,7 @@ suite('TextModelWithTokens regression tests', () => {
const tokenizationSupport: ITokenizationSupport = {
getInitialState: () => NULL_STATE,
tokenize: undefined,
tokenize: undefined!,
tokenize2: (line, state) => {
let tokens = new Uint32Array(2);
tokens[0] = 0;