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

@@ -6,7 +6,7 @@ import * as assert from 'assert';
import { DiffComputer } from 'vs/editor/common/diff/diffComputer';
import { IChange, ICharChange, ILineChange } from 'vs/editor/common/editorCommon';
function extractCharChangeRepresentation(change: ICharChange, expectedChange: ICharChange): ICharChange {
function extractCharChangeRepresentation(change: ICharChange, expectedChange: ICharChange | null): ICharChange {
let hasOriginal = expectedChange && expectedChange.originalStartLineNumber > 0;
let hasModified = expectedChange && expectedChange.modifiedStartLineNumber > 0;
return {
@@ -23,9 +23,8 @@ function extractCharChangeRepresentation(change: ICharChange, expectedChange: IC
}
function extractLineChangeRepresentation(change: ILineChange, expectedChange: ILineChange): IChange | ILineChange {
let charChanges: ICharChange[];
if (change.charChanges) {
charChanges = [];
let charChanges: ICharChange[] = [];
for (let i = 0; i < change.charChanges.length; i++) {
charChanges.push(
extractCharChangeRepresentation(
@@ -34,13 +33,20 @@ function extractLineChangeRepresentation(change: ILineChange, expectedChange: IL
)
);
}
return {
originalStartLineNumber: change.originalStartLineNumber,
originalEndLineNumber: change.originalEndLineNumber,
modifiedStartLineNumber: change.modifiedStartLineNumber,
modifiedEndLineNumber: change.modifiedEndLineNumber,
charChanges: charChanges
};
}
return {
originalStartLineNumber: change.originalStartLineNumber,
originalEndLineNumber: change.originalEndLineNumber,
modifiedStartLineNumber: change.modifiedStartLineNumber,
modifiedEndLineNumber: change.modifiedEndLineNumber,
charChanges: charChanges
charChanges: undefined
};
}

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;

View File

@@ -16,8 +16,8 @@ suite('LanguageSelector', function () {
test('score, invalid selector', function () {
assert.equal(score({}, model.uri, model.language, true), 0);
assert.equal(score(undefined, model.uri, model.language, true), 0);
assert.equal(score(null, model.uri, model.language, true), 0);
assert.equal(score(undefined!, model.uri, model.language, true), 0);
assert.equal(score(null!, model.uri, model.language, true), 0);
assert.equal(score('', model.uri, model.language, true), 0);
});

View File

@@ -12,7 +12,7 @@ import { TokenText, createFakeScopedLineTokens } from 'vs/editor/test/common/mod
const fakeLanguageIdentifier = new LanguageIdentifier('test', 3);
suite('Editor Modes - Auto Indentation', () => {
function _testOnElectricCharacter(electricCharacterSupport: BracketElectricCharacterSupport, line: TokenText[], character: string, offset: number): IElectricAction {
function _testOnElectricCharacter(electricCharacterSupport: BracketElectricCharacterSupport, line: TokenText[], character: string, offset: number): IElectricAction | null {
return electricCharacterSupport.onElectricCharacter(character, createFakeScopedLineTokens(line), offset);
}

View File

@@ -22,7 +22,7 @@ suite('OnEnter', () => {
if (expected === IndentAction.None) {
assert.equal(actual, null);
} else {
assert.equal(actual.indentAction, expected);
assert.equal(actual!.indentAction, expected);
}
};
@@ -50,18 +50,18 @@ suite('OnEnter', () => {
let support = new OnEnterSupport({
regExpRules: javascriptOnEnterRules
});
let testIndentAction = (oneLineAboveText: string, beforeText: string, afterText: string, expectedIndentAction: IndentAction, expectedAppendText: string, removeText: number = 0) => {
let testIndentAction = (oneLineAboveText: string, beforeText: string, afterText: string, expectedIndentAction: IndentAction | null, expectedAppendText: string | null, removeText: number = 0) => {
let actual = support.onEnter(oneLineAboveText, beforeText, afterText);
if (expectedIndentAction === null) {
assert.equal(actual, null, 'isNull:' + beforeText);
} else {
assert.equal(actual !== null, true, 'isNotNull:' + beforeText);
assert.equal(actual.indentAction, expectedIndentAction, 'indentAction:' + beforeText);
assert.equal(actual!.indentAction, expectedIndentAction, 'indentAction:' + beforeText);
if (expectedAppendText !== null) {
assert.equal(actual.appendText, expectedAppendText, 'appendText:' + beforeText);
assert.equal(actual!.appendText, expectedAppendText, 'appendText:' + beforeText);
}
if (removeText !== 0) {
assert.equal(actual.removeText, removeText, 'removeText:' + beforeText);
assert.equal(actual!.removeText, removeText, 'removeText:' + beforeText);
}
}
};

View File

@@ -9,60 +9,60 @@ import { BracketsUtils } from 'vs/editor/common/modes/supports/richEditBrackets'
suite('richEditBrackets', () => {
function findPrevBracketInToken(reversedBracketRegex: RegExp, lineText: string, currentTokenStart: number, currentTokenEnd: number): Range {
function findPrevBracketInToken(reversedBracketRegex: RegExp, lineText: string, currentTokenStart: number, currentTokenEnd: number): Range | null {
return BracketsUtils.findPrevBracketInToken(reversedBracketRegex, 1, lineText, currentTokenStart, currentTokenEnd);
}
function findNextBracketInToken(forwardBracketRegex: RegExp, lineText: string, currentTokenStart: number, currentTokenEnd: number): Range {
function findNextBracketInToken(forwardBracketRegex: RegExp, lineText: string, currentTokenStart: number, currentTokenEnd: number): Range | null {
return BracketsUtils.findNextBracketInToken(forwardBracketRegex, 1, lineText, currentTokenStart, currentTokenEnd);
}
test('findPrevBracketInToken one char 1', () => {
let result = findPrevBracketInToken(/(\{)|(\})/i, '{', 0, 1);
assert.equal(result.startColumn, 1);
assert.equal(result.endColumn, 2);
assert.equal(result!.startColumn, 1);
assert.equal(result!.endColumn, 2);
});
test('findPrevBracketInToken one char 2', () => {
let result = findPrevBracketInToken(/(\{)|(\})/i, '{{', 0, 1);
assert.equal(result.startColumn, 1);
assert.equal(result.endColumn, 2);
assert.equal(result!.startColumn, 1);
assert.equal(result!.endColumn, 2);
});
test('findPrevBracketInToken one char 3', () => {
let result = findPrevBracketInToken(/(\{)|(\})/i, '{hello world!', 0, 13);
assert.equal(result.startColumn, 1);
assert.equal(result.endColumn, 2);
assert.equal(result!.startColumn, 1);
assert.equal(result!.endColumn, 2);
});
test('findPrevBracketInToken more chars 1', () => {
let result = findPrevBracketInToken(/(olleh)/i, 'hello world!', 0, 12);
assert.equal(result.startColumn, 1);
assert.equal(result.endColumn, 6);
assert.equal(result!.startColumn, 1);
assert.equal(result!.endColumn, 6);
});
test('findPrevBracketInToken more chars 2', () => {
let result = findPrevBracketInToken(/(olleh)/i, 'hello world!', 0, 5);
assert.equal(result.startColumn, 1);
assert.equal(result.endColumn, 6);
assert.equal(result!.startColumn, 1);
assert.equal(result!.endColumn, 6);
});
test('findPrevBracketInToken more chars 3', () => {
let result = findPrevBracketInToken(/(olleh)/i, ' hello world!', 0, 6);
assert.equal(result.startColumn, 2);
assert.equal(result.endColumn, 7);
assert.equal(result!.startColumn, 2);
assert.equal(result!.endColumn, 7);
});
test('findNextBracketInToken one char', () => {
let result = findNextBracketInToken(/(\{)|(\})/i, '{', 0, 1);
assert.equal(result.startColumn, 1);
assert.equal(result.endColumn, 2);
assert.equal(result!.startColumn, 1);
assert.equal(result!.endColumn, 2);
});
test('findNextBracketInToken more chars', () => {
let result = findNextBracketInToken(/(world)/i, 'hello world!', 0, 12);
assert.equal(result.startColumn, 7);
assert.equal(result.endColumn, 12);
assert.equal(result!.startColumn, 7);
assert.equal(result!.endColumn, 12);
});
test('findNextBracketInToken with emoty result', () => {
@@ -72,8 +72,8 @@ suite('richEditBrackets', () => {
test('issue #3894: [Handlebars] Curly braces edit issues', () => {
let result = findPrevBracketInToken(/(\-\-!<)|(>\-\-)|(\{\{)|(\}\})/i, '{{asd}}', 0, 2);
assert.equal(result.startColumn, 1);
assert.equal(result.endColumn, 3);
assert.equal(result!.startColumn, 1);
assert.equal(result!.endColumn, 3);
});
});

View File

@@ -102,7 +102,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
) >>> 0
)
]);
const colorMap = [null, '#000000', '#ffffff', '#ff0000', '#00ff00', '#0000ff'];
const colorMap = [null!, '#000000', '#ffffff', '#ff0000', '#00ff00', '#0000ff'];
assert.equal(
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 17, 4),
@@ -203,8 +203,8 @@ class Mode extends MockMode {
constructor() {
super(Mode._id);
this._register(TokenizationRegistry.register(this.getId(), {
getInitialState: (): IState => null,
tokenize: undefined,
getInitialState: (): IState => null!,
tokenize: undefined!,
tokenize2: (line: string, state: IState): TokenizationResult2 => {
let tokensArr: number[] = [];
let prevColor: ColorId = -1;
@@ -223,7 +223,7 @@ class Mode extends MockMode {
for (let i = 0; i < tokens.length; i++) {
tokens[i] = tokensArr[i];
}
return new TokenizationResult2(tokens, null);
return new TokenizationResult2(tokens, null!);
}
}));
}

View File

@@ -162,6 +162,10 @@ suite('EditorSimpleWorker', () => {
]);
return worker.textualSuggest(model.uri.toString(), { lineNumber: 2, column: 2 }, '[a-z]+', 'img').then((result) => {
if (!result) {
assert.ok(false);
return;
}
const { suggestions } = result;
assert.equal(suggestions.length, 1);
assert.equal(suggestions[0].label, 'foobar');

View File

@@ -15,7 +15,7 @@ suite('LanguagesRegistry', () => {
registry._registerLanguages([{
id: 'outputModeId',
extensions: [],
aliases: [null],
aliases: [],
mimetypes: ['outputModeMimeType'],
}]);

View File

@@ -27,7 +27,7 @@ suite('ModelService', () => {
configService.setUserConfiguration('files', { 'eol': '\n' });
configService.setUserConfiguration('files', { 'eol': '\r\n' }, URI.file(platform.isWindows ? 'c:\\myroot' : '/myroot'));
modelService = new ModelServiceImpl(null, configService, new TestTextResourcePropertiesService(configService));
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService));
});
teardown(() => {
@@ -313,7 +313,7 @@ function assertComputeEdits(lines1: string[], lines2: string[]): void {
// console.log(`took ${Date.now() - start} ms.`);
// apply edits
model.pushEditOperations(null, edits, null);
model.pushEditOperations([], edits, null);
assert.equal(model.getValue(), lines2.join('\n'));
}
@@ -370,7 +370,7 @@ class TestTextResourcePropertiesService implements ITextResourcePropertiesServic
_serviceBrand: any;
constructor(
@IConfigurationService private configurationService: IConfigurationService,
@IConfigurationService private readonly configurationService: IConfigurationService,
) {
}

View File

@@ -11,7 +11,7 @@ import { MinimapCharRendererFactory } from 'vs/editor/test/common/view/minimapCh
suite('MinimapCharRenderer', () => {
let sampleData: Uint8ClampedArray = null;
let sampleData: Uint8ClampedArray | null = null;
suiteSetup(() => {
sampleData = new Uint8ClampedArray(Constants.SAMPLED_CHAR_HEIGHT * Constants.SAMPLED_CHAR_WIDTH * Constants.RGBA_CHANNELS_CNT * Constants.CHAR_COUNT);
@@ -22,25 +22,24 @@ suite('MinimapCharRenderer', () => {
});
setup(() => {
for (let i = 0; i < sampleData.length; i++) {
sampleData[i] = 0;
for (let i = 0; i < sampleData!.length; i++) {
sampleData![i] = 0;
}
});
const sampleD = [
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xd0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xd0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xd0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x0d, 0xff, 0xff, 0xff, 0xa3, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xe5, 0xff, 0xff, 0xff, 0x5e, 0xff, 0xff, 0xff, 0xd0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xa4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0x10, 0xff, 0xff, 0xff, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x94, 0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x6a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0x3b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x22, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0x47, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xd6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0x31, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0x0e, 0xff, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x69, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x9b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xb9, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x0e, 0xff, 0xff, 0xff, 0xa7, 0xff, 0xff, 0xff, 0xf5, 0xff, 0xff, 0xff, 0xe8, 0xff, 0xff, 0xff, 0x71, 0xff, 0xff, 0xff, 0xd0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xD0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xD0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xD0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x0D, 0xFF, 0xFF, 0xFF, 0xA3, 0xFF, 0xFF, 0xFF, 0xF3, 0xFF, 0xFF, 0xFF, 0xE5, 0xFF, 0xFF, 0xFF, 0x5E, 0xFF, 0xFF, 0xFF, 0xD0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xA4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0xFC, 0xFF, 0xFF, 0xFF, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0x10, 0xFF, 0xFF, 0xFF, 0xFB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x94, 0xFF, 0xFF, 0xFF, 0x02, 0xFF, 0xFF, 0xFF, 0x6A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0x3B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x22, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x03, 0xFF, 0xFF, 0xFF, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xD6, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0x31, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0x0E, 0xFF, 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x69, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x3D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x9B, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF9, 0xFF, 0xFF, 0xFF, 0xB9, 0xFF, 0xFF, 0xFF, 0xF0, 0xFF, 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x0E, 0xFF, 0xFF, 0xFF, 0xA7, 0xFF, 0xFF, 0xFF, 0xF5, 0xFF, 0xFF, 0xFF, 0xE8, 0xFF, 0xFF, 0xFF, 0x71, 0xFF, 0xFF, 0xFF, 0xD0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -57,7 +56,7 @@ suite('MinimapCharRenderer', () => {
let outputOffset = globalOutputOffset;
for (let j = 0; j < Constants.SAMPLED_CHAR_WIDTH; j++) {
for (let channel = 0; channel < Constants.RGBA_CHANNELS_CNT; channel++) {
sampleData[outputOffset] = data[inputOffset];
sampleData![outputOffset] = data[inputOffset];
inputOffset++;
outputOffset++;
}
@@ -76,7 +75,7 @@ suite('MinimapCharRenderer', () => {
test('letter d @ 2x', () => {
setSampleData('d'.charCodeAt(0), sampleD);
let renderer = MinimapCharRendererFactory.create(sampleData);
let renderer = MinimapCharRendererFactory.create(sampleData!);
let background = new RGBA8(0, 0, 0, 255);
let color = new RGBA8(255, 255, 255, 255);
@@ -95,10 +94,10 @@ suite('MinimapCharRenderer', () => {
actual[i] = imageData.data[i];
}
assert.deepEqual(actual, [
0x00, 0x00, 0x00, 0xff, 0x6d, 0x6d, 0x6d, 0xff,
0xbb, 0xbb, 0xbb, 0xff, 0xbe, 0xbe, 0xbe, 0xff,
0x94, 0x94, 0x94, 0xff, 0x7e, 0x7e, 0x7e, 0xff,
0xb1, 0xb1, 0xb1, 0xff, 0xbb, 0xbb, 0xbb, 0xff,
0x00, 0x00, 0x00, 0xFF, 0x6D, 0x6D, 0x6D, 0xFF,
0xBB, 0xBB, 0xBB, 0xFF, 0xBE, 0xBE, 0xBE, 0xFF,
0x94, 0x94, 0x94, 0xFF, 0x7E, 0x7E, 0x7E, 0xFF,
0xB1, 0xB1, 0xB1, 0xFF, 0xBB, 0xBB, 0xBB, 0xFF,
]);
});
@@ -123,16 +122,16 @@ suite('MinimapCharRenderer', () => {
actual[i] = imageData.data[i];
}
assert.deepEqual(actual, [
0x00, 0x00, 0x00, 0xff, 0x6d, 0x6d, 0x6d, 0xff,
0xbb, 0xbb, 0xbb, 0xff, 0xbe, 0xbe, 0xbe, 0xff,
0x94, 0x94, 0x94, 0xff, 0x7e, 0x7e, 0x7e, 0xff,
0xb1, 0xb1, 0xb1, 0xff, 0xbb, 0xbb, 0xbb, 0xff,
0x00, 0x00, 0x00, 0xFF, 0x6D, 0x6D, 0x6D, 0xFF,
0xBB, 0xBB, 0xBB, 0xFF, 0xBE, 0xBE, 0xBE, 0xFF,
0x94, 0x94, 0x94, 0xFF, 0x7E, 0x7E, 0x7E, 0xFF,
0xB1, 0xB1, 0xB1, 0xFF, 0xBB, 0xBB, 0xBB, 0xFF,
]);
});
test('letter d @ 1x', () => {
setSampleData('d'.charCodeAt(0), sampleD);
let renderer = MinimapCharRendererFactory.create(sampleData);
let renderer = MinimapCharRendererFactory.create(sampleData!);
let background = new RGBA8(0, 0, 0, 255);
let color = new RGBA8(255, 255, 255, 255);
@@ -152,8 +151,8 @@ suite('MinimapCharRenderer', () => {
actual[i] = imageData.data[i];
}
assert.deepEqual(actual, [
0x55, 0x55, 0x55, 0xff,
0x93, 0x93, 0x93, 0xff,
0x55, 0x55, 0x55, 0xFF,
0x93, 0x93, 0x93, 0xFF,
]);
});
@@ -178,8 +177,8 @@ suite('MinimapCharRenderer', () => {
actual[i] = imageData.data[i];
}
assert.deepEqual(actual, [
0x55, 0x55, 0x55, 0xff,
0x93, 0x93, 0x93, 0xff,
0x55, 0x55, 0x55, 0xFF,
0x93, 0x93, 0x93, 0xFF,
]);
});

View File

@@ -563,13 +563,13 @@ suite('Editor ViewLayout - LinesLayout', () => {
assert.equal(whitespace, null);
whitespace = linesLayout.getWhitespaceAtVerticalOffset(60);
assert.equal(whitespace.id, a);
assert.equal(whitespace!.id, a);
whitespace = linesLayout.getWhitespaceAtVerticalOffset(61);
assert.equal(whitespace.id, a);
assert.equal(whitespace!.id, a);
whitespace = linesLayout.getWhitespaceAtVerticalOffset(159);
assert.equal(whitespace.id, a);
assert.equal(whitespace!.id, a);
whitespace = linesLayout.getWhitespaceAtVerticalOffset(160);
assert.equal(whitespace, null);
@@ -581,13 +581,13 @@ suite('Editor ViewLayout - LinesLayout', () => {
assert.equal(whitespace, null);
whitespace = linesLayout.getWhitespaceAtVerticalOffset(170);
assert.equal(whitespace.id, b);
assert.equal(whitespace!.id, b);
whitespace = linesLayout.getWhitespaceAtVerticalOffset(171);
assert.equal(whitespace.id, b);
assert.equal(whitespace!.id, b);
whitespace = linesLayout.getWhitespaceAtVerticalOffset(219);
assert.equal(whitespace.id, b);
assert.equal(whitespace!.id, b);
whitespace = linesLayout.getWhitespaceAtVerticalOffset(220);
assert.equal(whitespace, null);

View File

@@ -653,8 +653,7 @@ suite('viewLineRenderer.renderLine', () => {
for (let partIndex = 0; partIndex < expectedCharPartOffsets.length; partIndex++) {
const part = expectedCharPartOffsets[partIndex];
for (let i = 0; i < part.length; i++) {
const charIndex = part[i];
for (const charIndex of part) {
expectedCharAbsoluteOffset.push(currentPartAbsoluteOffset + charIndex);
}
@@ -674,8 +673,7 @@ suite('viewLineRenderer.renderLine', () => {
let charOffset = 0;
for (let partIndex = 0; partIndex < expected.length; partIndex++) {
let part = expected[partIndex];
for (let i = 0; i < part.length; i++) {
let charIndex = part[i];
for (const charIndex of part) {
// here
let _actualPartData = actual.charOffsetToPartData(charOffset);
let actualPartIndex = CharacterMapping.getPartIndex(_actualPartData);

View File

@@ -7,7 +7,7 @@ import { WrappingIndent } from 'vs/editor/common/config/editorOptions';
import { CharacterHardWrappingLineMapperFactory } from 'vs/editor/common/viewModel/characterHardWrappingLineMapper';
import { ILineMapperFactory, ILineMapping } from 'vs/editor/common/viewModel/splitLinesCollection';
function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAfter: number, annotatedText: string, wrappingIndent = WrappingIndent.None): ILineMapping {
function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAfter: number, annotatedText: string, wrappingIndent = WrappingIndent.None): ILineMapping | null {
// Create version of `annotatedText` with line break markers removed
let rawText = '';
let currentLineIndex = 0;
@@ -21,7 +21,7 @@ function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAf
}
}
let mapper = factory.createLineMapping(rawText, tabSize, breakAfter, 2, wrappingIndent);
const mapper = factory.createLineMapping(rawText, tabSize, breakAfter, 2, wrappingIndent);
// Insert line break markers again, according to algorithm
let actualAnnotatedText = '';
@@ -111,12 +111,12 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
test('issue #35162: wrappingIndent not consistently working', () => {
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
let mapper = assertLineMapping(factory, 4, 24, ' t h i s |i s |a l |o n |g l |i n |e', WrappingIndent.Indent);
assert.equal(mapper.getWrappedLinesIndent(), ' \t');
assert.equal(mapper!.getWrappedLinesIndent(), ' \t');
});
test('CharacterHardWrappingLineMapper - WrappingIndent.DeepIndent', () => {
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
let mapper = assertLineMapping(factory, 4, 26, ' W e A r e T e s t |i n g D e |e p I n d |e n t a t |i o n', WrappingIndent.DeepIndent);
assert.equal(mapper.getWrappedLinesIndent(), ' \t\t');
assert.equal(mapper!.getWrappedLinesIndent(), ' \t\t');
});
});

View File

@@ -329,7 +329,7 @@ suite('SplitLinesCollection', () => {
let _lineIndex = 0;
const tokenizationSupport: modes.ITokenizationSupport = {
getInitialState: () => NULL_STATE,
tokenize: undefined,
tokenize: undefined!,
tokenize2: (line: string, state: modes.IState): TokenizationResult2 => {
let tokens = _tokens[_lineIndex++];
@@ -351,9 +351,9 @@ suite('SplitLinesCollection', () => {
});
teardown(() => {
model.dispose();
model!.dispose();
model = null;
languageRegistration.dispose();
languageRegistration!.dispose();
languageRegistration = null;
});
@@ -381,18 +381,22 @@ suite('SplitLinesCollection', () => {
tokens: ITestViewLineToken[];
}
function assertMinimapLineRenderingData(actual: ViewLineData, expected: ITestMinimapLineRenderingData): void {
function assertMinimapLineRenderingData(actual: ViewLineData, expected: ITestMinimapLineRenderingData | null): void {
if (actual === null && expected === null) {
assert.ok(true);
return;
}
if (expected === null) {
assert.ok(false);
return;
}
assert.equal(actual.content, expected.content);
assert.equal(actual.minColumn, expected.minColumn);
assert.equal(actual.maxColumn, expected.maxColumn);
assertViewLineTokens(actual.tokens, expected.tokens);
}
function assertMinimapLinesRenderingData(actual: ViewLineData[], expected: ITestMinimapLineRenderingData[]): void {
function assertMinimapLinesRenderingData(actual: ViewLineData[], expected: Array<ITestMinimapLineRenderingData | null>): void {
assert.equal(actual.length, expected.length);
for (let i = 0; i < expected.length; i++) {
assertMinimapLineRenderingData(actual[i], expected[i]);
@@ -406,7 +410,7 @@ suite('SplitLinesCollection', () => {
let count = end - start + 1;
for (let desired = Math.pow(2, count) - 1; desired >= 0; desired--) {
let needed: boolean[] = [];
let expected: ITestMinimapLineRenderingData[] = [];
let expected: Array<ITestMinimapLineRenderingData | null> = [];
for (let i = 0; i < count; i++) {
needed[i] = (desired & (1 << i)) ? true : false;
expected[i] = (needed[i] ? all[start - 1 + i] : null);
@@ -421,7 +425,7 @@ suite('SplitLinesCollection', () => {
}
test('getViewLinesData - no wrapping', () => {
withSplitLinesCollection(model, 'off', 0, (splitLinesCollection) => {
withSplitLinesCollection(model!, 'off', 0, (splitLinesCollection) => {
assert.equal(splitLinesCollection.getViewLineCount(), 8);
assert.equal(splitLinesCollection.modelPositionIsVisible(1, 1), true);
assert.equal(splitLinesCollection.modelPositionIsVisible(2, 1), true);
@@ -555,7 +559,7 @@ suite('SplitLinesCollection', () => {
});
test('getViewLinesData - with wrapping', () => {
withSplitLinesCollection(model, 'wordWrapColumn', 30, (splitLinesCollection) => {
withSplitLinesCollection(model!, 'wordWrapColumn', 30, (splitLinesCollection) => {
assert.equal(splitLinesCollection.getViewLineCount(), 12);
assert.equal(splitLinesCollection.modelPositionIsVisible(1, 1), true);
assert.equal(splitLinesCollection.modelPositionIsVisible(2, 1), true);
@@ -774,7 +778,7 @@ function createLineMapping(breakingLengths: number[], wrappedLinesPrefix: string
function createModel(text: string): ISimpleModel {
return {
getLineTokens: (lineNumber: number) => {
return null;
return null!;
},
getLineContent: (lineNumber: number) => {
return text;