mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 18:46:34 -05:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -12,6 +12,12 @@ import { EditableTextModel, IValidatedEditOperation } from 'vs/editor/common/mod
|
||||
import { MirrorModel } from 'vs/editor/common/model/mirrorModel';
|
||||
import { assertSyncedModels, testApplyEditsWithSyncedModels } from 'vs/editor/test/common/model/editableTextModelTestUtils';
|
||||
import { IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvents';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { RawTextSource } from 'vs/editor/common/model/textSource';
|
||||
|
||||
function createEditableTextModelFromString(text: string): EditableTextModel {
|
||||
return new EditableTextModel(RawTextSource.fromString(text), TextModel.DEFAULT_CREATION_OPTIONS, null);
|
||||
}
|
||||
|
||||
suite('EditorModel - EditableTextModel._getInverseEdits', () => {
|
||||
|
||||
@@ -280,7 +286,7 @@ suite('EditorModel - EditableTextModel._toSingleEditOperation', () => {
|
||||
}
|
||||
|
||||
function testSimpleApplyEdits(original: string[], edits: IValidatedEditOperation[], expected: IValidatedEditOperation): void {
|
||||
let model = EditableTextModel.createFromString(original.join('\n'));
|
||||
let model = createEditableTextModelFromString(original.join('\n'));
|
||||
model.setEOL(EndOfLineSequence.LF);
|
||||
|
||||
let actual = model._toSingleEditOperation(edits);
|
||||
@@ -522,7 +528,7 @@ suite('EditorModel - EditableTextModel._toSingleEditOperation', () => {
|
||||
suite('EditorModel - EditableTextModel.applyEdits updates mightContainRTL', () => {
|
||||
|
||||
function testApplyEdits(original: string[], edits: IIdentifiedSingleEditOperation[], before: boolean, after: boolean): void {
|
||||
let model = EditableTextModel.createFromString(original.join('\n'));
|
||||
let model = createEditableTextModelFromString(original.join('\n'));
|
||||
model.setEOL(EndOfLineSequence.LF);
|
||||
|
||||
assert.equal(model.mightContainRTL(), before);
|
||||
@@ -570,7 +576,7 @@ suite('EditorModel - EditableTextModel.applyEdits updates mightContainRTL', () =
|
||||
suite('EditorModel - EditableTextModel.applyEdits updates mightContainNonBasicASCII', () => {
|
||||
|
||||
function testApplyEdits(original: string[], edits: IIdentifiedSingleEditOperation[], before: boolean, after: boolean): void {
|
||||
let model = EditableTextModel.createFromString(original.join('\n'));
|
||||
let model = createEditableTextModelFromString(original.join('\n'));
|
||||
model.setEOL(EndOfLineSequence.LF);
|
||||
|
||||
assert.equal(model.mightContainNonBasicASCII(), before);
|
||||
@@ -1365,7 +1371,7 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
|
||||
});
|
||||
|
||||
function testApplyEditsFails(original: string[], edits: IIdentifiedSingleEditOperation[]): void {
|
||||
let model = EditableTextModel.createFromString(original.join('\n'));
|
||||
let model = createEditableTextModelFromString(original.join('\n'));
|
||||
|
||||
let hasThrown = false;
|
||||
try {
|
||||
@@ -1506,7 +1512,7 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
|
||||
|
||||
}, (model) => {
|
||||
var isFirstTime = true;
|
||||
model.addBulkListener((events) => {
|
||||
model.onDidChangeRawContent(() => {
|
||||
if (!isFirstTime) {
|
||||
return;
|
||||
}
|
||||
@@ -1553,7 +1559,7 @@ suite('EditorModel - EditableTextModel.applyEdits', () => {
|
||||
});
|
||||
|
||||
test('issue #1580: Changes in line endings are not correctly reflected in the extension host, leading to invalid offsets sent to external refactoring tools', () => {
|
||||
let model = EditableTextModel.createFromString('Hello\nWorld!');
|
||||
let model = createEditableTextModelFromString('Hello\nWorld!');
|
||||
assert.equal(model.getEOL(), '\n');
|
||||
|
||||
let mirrorModel2 = new MirrorModel(null, model.getLinesContent(), model.getEOL(), model.getVersionId());
|
||||
|
||||
@@ -1,388 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Model } from 'vs/editor/common/model/model';
|
||||
import { computeRanges, MAX_FOLDING_REGIONS } from 'vs/editor/common/model/indentRanges';
|
||||
import { FoldingMarkers } from 'vs/editor/common/modes/languageConfiguration';
|
||||
|
||||
export interface ExpectedIndentRange {
|
||||
startLineNumber: number;
|
||||
endLineNumber: number;
|
||||
indent: number;
|
||||
parentIndex: number;
|
||||
}
|
||||
|
||||
function assertRanges(lines: string[], expected: ExpectedIndentRange[], offside: boolean, markers?: FoldingMarkers): void {
|
||||
let model = Model.createFromString(lines.join('\n'));
|
||||
let actual = computeRanges(model, offside, markers);
|
||||
|
||||
let actualRanges = [];
|
||||
for (let i = 0; i < actual.length; i++) {
|
||||
actualRanges[i] = r(actual.getStartLineNumber(i), actual.getEndLineNumber(i), actual.getIndent(i), actual.getParentIndex(i));
|
||||
}
|
||||
assert.deepEqual(actualRanges, expected);
|
||||
model.dispose();
|
||||
}
|
||||
|
||||
function r(startLineNumber: number, endLineNumber: number, indent: number, parentIndex: number, marker = false): ExpectedIndentRange {
|
||||
return { startLineNumber, endLineNumber, indent, parentIndex };
|
||||
}
|
||||
|
||||
suite('Indentation Folding', () => {
|
||||
test('Fold one level', () => {
|
||||
let range = [
|
||||
'A',
|
||||
' A',
|
||||
' A',
|
||||
' A'
|
||||
];
|
||||
assertRanges(range, [r(1, 4, 0, -1)], true);
|
||||
assertRanges(range, [r(1, 4, 0, -1)], false);
|
||||
});
|
||||
|
||||
test('Fold two levels', () => {
|
||||
let range = [
|
||||
'A',
|
||||
' A',
|
||||
' A',
|
||||
' A',
|
||||
' A'
|
||||
];
|
||||
assertRanges(range, [r(1, 5, 0, -1), r(3, 5, 2, 0)], true);
|
||||
assertRanges(range, [r(1, 5, 0, -1), r(3, 5, 2, 0)], false);
|
||||
});
|
||||
|
||||
test('Fold three levels', () => {
|
||||
let range = [
|
||||
'A',
|
||||
' A',
|
||||
' A',
|
||||
' A',
|
||||
'A'
|
||||
];
|
||||
assertRanges(range, [r(1, 4, 0, -1), r(2, 4, 2, 0), r(3, 4, 4, 1)], true);
|
||||
assertRanges(range, [r(1, 4, 0, -1), r(2, 4, 2, 0), r(3, 4, 4, 1)], false);
|
||||
});
|
||||
|
||||
test('Fold decreasing indent', () => {
|
||||
let range = [
|
||||
' A',
|
||||
' A',
|
||||
'A'
|
||||
];
|
||||
assertRanges(range, [], true);
|
||||
assertRanges(range, [], false);
|
||||
});
|
||||
|
||||
test('Fold Java', () => {
|
||||
assertRanges([
|
||||
/* 1*/ 'class A {',
|
||||
/* 2*/ ' void foo() {',
|
||||
/* 3*/ ' console.log();',
|
||||
/* 4*/ ' console.log();',
|
||||
/* 5*/ ' }',
|
||||
/* 6*/ '',
|
||||
/* 7*/ ' void bar() {',
|
||||
/* 8*/ ' console.log();',
|
||||
/* 9*/ ' }',
|
||||
/*10*/ '}',
|
||||
/*11*/ 'interface B {',
|
||||
/*12*/ ' void bar();',
|
||||
/*13*/ '}',
|
||||
], [r(1, 9, 0, -1), r(2, 4, 2, 0), r(7, 8, 2, 0), r(11, 12, 0, -1)], false);
|
||||
});
|
||||
|
||||
test('Fold Javadoc', () => {
|
||||
assertRanges([
|
||||
/* 1*/ '/**',
|
||||
/* 2*/ ' * Comment',
|
||||
/* 3*/ ' */',
|
||||
/* 4*/ 'class A {',
|
||||
/* 5*/ ' void foo() {',
|
||||
/* 6*/ ' }',
|
||||
/* 7*/ '}',
|
||||
], [r(1, 3, 0, -1), r(4, 6, 0, -1)], false);
|
||||
});
|
||||
test('Fold Whitespace Java', () => {
|
||||
assertRanges([
|
||||
/* 1*/ 'class A {',
|
||||
/* 2*/ '',
|
||||
/* 3*/ ' void foo() {',
|
||||
/* 4*/ ' ',
|
||||
/* 5*/ ' return 0;',
|
||||
/* 6*/ ' }',
|
||||
/* 7*/ ' ',
|
||||
/* 8*/ '}',
|
||||
], [r(1, 7, 0, -1), r(3, 5, 2, 0)], false);
|
||||
});
|
||||
|
||||
test('Fold Whitespace Python', () => {
|
||||
assertRanges([
|
||||
/* 1*/ 'def a:',
|
||||
/* 2*/ ' pass',
|
||||
/* 3*/ ' ',
|
||||
/* 4*/ ' def b:',
|
||||
/* 5*/ ' pass',
|
||||
/* 6*/ ' ',
|
||||
/* 7*/ ' ',
|
||||
/* 8*/ 'def c: # since there was a deintent here'
|
||||
], [r(1, 5, 0, -1), r(4, 5, 2, 0)], true);
|
||||
});
|
||||
|
||||
test('Fold Tabs', () => {
|
||||
assertRanges([
|
||||
/* 1*/ 'class A {',
|
||||
/* 2*/ '\t\t',
|
||||
/* 3*/ '\tvoid foo() {',
|
||||
/* 4*/ '\t \t//hello',
|
||||
/* 5*/ '\t return 0;',
|
||||
/* 6*/ ' \t}',
|
||||
/* 7*/ ' ',
|
||||
/* 8*/ '}',
|
||||
], [r(1, 7, 0, -1), r(3, 5, 4, 0)], false);
|
||||
});
|
||||
});
|
||||
|
||||
let markers: FoldingMarkers = {
|
||||
start: /^\s*#region\b/,
|
||||
end: /^\s*#endregion\b/
|
||||
};
|
||||
|
||||
suite('Folding with regions', () => {
|
||||
test('Inside region, indented', () => {
|
||||
assertRanges([
|
||||
/* 1*/ 'class A {',
|
||||
/* 2*/ ' #region',
|
||||
/* 3*/ ' void foo() {',
|
||||
/* 4*/ ' ',
|
||||
/* 5*/ ' return 0;',
|
||||
/* 6*/ ' }',
|
||||
/* 7*/ ' #endregion',
|
||||
/* 8*/ '}',
|
||||
], [r(1, 7, 0, -1), r(2, 7, 2, 0, true), r(3, 5, 2, 1)], false, markers);
|
||||
});
|
||||
test('Inside region, not indented', () => {
|
||||
assertRanges([
|
||||
/* 1*/ 'var x;',
|
||||
/* 2*/ '#region',
|
||||
/* 3*/ 'void foo() {',
|
||||
/* 4*/ ' ',
|
||||
/* 5*/ ' return 0;',
|
||||
/* 6*/ ' }',
|
||||
/* 7*/ '#endregion',
|
||||
/* 8*/ '',
|
||||
], [r(2, 7, 0, -1, true), r(3, 6, 0, 0)], false, markers);
|
||||
});
|
||||
test('Empty Regions', () => {
|
||||
assertRanges([
|
||||
/* 1*/ 'var x;',
|
||||
/* 2*/ '#region',
|
||||
/* 3*/ '#endregion',
|
||||
/* 4*/ '#region',
|
||||
/* 5*/ '',
|
||||
/* 6*/ '#endregion',
|
||||
/* 7*/ 'var y;',
|
||||
], [r(2, 3, 0, -1, true), r(4, 6, 0, -1, true)], false, markers);
|
||||
});
|
||||
test('Nested Regions', () => {
|
||||
assertRanges([
|
||||
/* 1*/ 'var x;',
|
||||
/* 2*/ '#region',
|
||||
/* 3*/ '#region',
|
||||
/* 4*/ '',
|
||||
/* 5*/ '#endregion',
|
||||
/* 6*/ '#endregion',
|
||||
/* 7*/ 'var y;',
|
||||
], [r(2, 6, 0, -1, true), r(3, 5, 0, 0, true)], false, markers);
|
||||
});
|
||||
test('Nested Regions 2', () => {
|
||||
assertRanges([
|
||||
/* 1*/ 'class A {',
|
||||
/* 2*/ ' #region',
|
||||
/* 3*/ '',
|
||||
/* 4*/ ' #region',
|
||||
/* 5*/ '',
|
||||
/* 6*/ ' #endregion',
|
||||
/* 7*/ ' // comment',
|
||||
/* 8*/ ' #endregion',
|
||||
/* 9*/ '}',
|
||||
], [r(1, 8, 0, -1), r(2, 8, 2, 0, true), r(4, 6, 2, 1, true)], false, markers);
|
||||
});
|
||||
test('Incomplete Regions', () => {
|
||||
assertRanges([
|
||||
/* 1*/ 'class A {',
|
||||
/* 2*/ '#region',
|
||||
/* 3*/ ' // comment',
|
||||
/* 4*/ '}',
|
||||
], [r(2, 3, 0, -1)], false, markers);
|
||||
});
|
||||
test('Incomplete Regions 2', () => {
|
||||
assertRanges([
|
||||
/* 1*/ '',
|
||||
/* 2*/ '#region',
|
||||
/* 3*/ '#region',
|
||||
/* 4*/ '#region',
|
||||
/* 5*/ ' // comment',
|
||||
/* 6*/ '#endregion',
|
||||
/* 7*/ '#endregion',
|
||||
/* 8*/ ' // hello',
|
||||
], [r(3, 7, 0, -1, true), r(4, 6, 0, 0, true)], false, markers);
|
||||
});
|
||||
test('Indented region before', () => {
|
||||
assertRanges([
|
||||
/* 1*/ 'if (x)',
|
||||
/* 2*/ ' return;',
|
||||
/* 3*/ '',
|
||||
/* 4*/ '#region',
|
||||
/* 5*/ ' // comment',
|
||||
/* 6*/ '#endregion',
|
||||
], [r(1, 3, 0, -1), r(4, 6, 0, -1, true)], false, markers);
|
||||
});
|
||||
test('Indented region before 2', () => {
|
||||
assertRanges([
|
||||
/* 1*/ 'if (x)',
|
||||
/* 2*/ ' log();',
|
||||
/* 3*/ '',
|
||||
/* 4*/ ' #region',
|
||||
/* 5*/ ' // comment',
|
||||
/* 6*/ ' #endregion',
|
||||
], [r(1, 6, 0, -1), r(2, 6, 2, 0), r(4, 6, 4, 1, true)], false, markers);
|
||||
});
|
||||
test('Indented region in-between', () => {
|
||||
assertRanges([
|
||||
/* 1*/ '#region',
|
||||
/* 2*/ ' // comment',
|
||||
/* 3*/ ' if (x)',
|
||||
/* 4*/ ' return;',
|
||||
/* 5*/ '',
|
||||
/* 6*/ '#endregion',
|
||||
], [r(1, 6, 0, -1, true), r(3, 5, 2, 0)], false, markers);
|
||||
});
|
||||
test('Indented region after', () => {
|
||||
assertRanges([
|
||||
/* 1*/ '#region',
|
||||
/* 2*/ ' // comment',
|
||||
/* 3*/ '',
|
||||
/* 4*/ '#endregion',
|
||||
/* 5*/ ' if (x)',
|
||||
/* 6*/ ' return;',
|
||||
], [r(1, 4, 0, -1, true), r(5, 6, 2, -1)], false, markers);
|
||||
});
|
||||
test('With off-side', () => {
|
||||
assertRanges([
|
||||
/* 1*/ '#region',
|
||||
/* 2*/ ' ',
|
||||
/* 3*/ '',
|
||||
/* 4*/ '#endregion',
|
||||
/* 5*/ '',
|
||||
], [r(1, 4, 0, -1, true)], true, markers);
|
||||
});
|
||||
test('Nested with off-side', () => {
|
||||
assertRanges([
|
||||
/* 1*/ '#region',
|
||||
/* 2*/ ' ',
|
||||
/* 3*/ '#region',
|
||||
/* 4*/ '',
|
||||
/* 5*/ '#endregion',
|
||||
/* 6*/ '',
|
||||
/* 7*/ '#endregion',
|
||||
/* 8*/ '',
|
||||
], [r(1, 7, 0, -1, true), r(3, 5, 0, 0, true)], true, markers);
|
||||
});
|
||||
test('Issue 35981', () => {
|
||||
assertRanges([
|
||||
/* 1*/ 'function thisFoldsToEndOfPage() {',
|
||||
/* 2*/ ' const variable = []',
|
||||
/* 3*/ ' // #region',
|
||||
/* 4*/ ' .reduce((a, b) => a,[]);',
|
||||
/* 5*/ '}',
|
||||
/* 6*/ '',
|
||||
/* 7*/ 'function thisFoldsProperly() {',
|
||||
/* 8*/ ' const foo = "bar"',
|
||||
/* 9*/ '}',
|
||||
], [r(1, 4, 0, -1), r(2, 4, 2, 0), r(7, 8, 0, -1)], false, markers);
|
||||
});
|
||||
test('Misspelled Markers', () => {
|
||||
assertRanges([
|
||||
/* 1*/ '#Region',
|
||||
/* 2*/ '#endregion',
|
||||
/* 3*/ '#regionsandmore',
|
||||
/* 4*/ '#endregion',
|
||||
/* 5*/ '#region',
|
||||
/* 6*/ '#end region',
|
||||
/* 7*/ '#region',
|
||||
/* 8*/ '#endregionff',
|
||||
], [], true, markers);
|
||||
});
|
||||
|
||||
test('test max folding regions', () => {
|
||||
let lines = [];
|
||||
let nRegions = MAX_FOLDING_REGIONS;
|
||||
for (let i = 0; i < nRegions; i++) {
|
||||
lines.push('#region');
|
||||
}
|
||||
for (let i = 0; i < nRegions; i++) {
|
||||
lines.push('#endregion');
|
||||
}
|
||||
let model = Model.createFromString(lines.join('\n'));
|
||||
let actual = computeRanges(model, false, markers, MAX_FOLDING_REGIONS);
|
||||
assert.equal(actual.length, nRegions, 'len');
|
||||
for (let i = 0; i < nRegions; i++) {
|
||||
assert.equal(actual.getStartLineNumber(i), i + 1, 'start' + i);
|
||||
assert.equal(actual.getEndLineNumber(i), nRegions * 2 - i, 'end' + i);
|
||||
assert.equal(actual.getParentIndex(i), i - 1, 'parent' + i);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
test('findRange', () => {
|
||||
let lines = [
|
||||
/* 1*/ '#region',
|
||||
/* 2*/ '#endregion',
|
||||
/* 3*/ 'class A {',
|
||||
/* 4*/ ' void foo() {',
|
||||
/* 5*/ ' if (true) {',
|
||||
/* 6*/ ' return;',
|
||||
/* 7*/ ' }',
|
||||
/* 8*/ '',
|
||||
/* 9*/ ' if (true) {',
|
||||
/* 10*/ ' return;',
|
||||
/* 11*/ ' }',
|
||||
/* 12*/ ' }',
|
||||
/* 13*/ '}'];
|
||||
|
||||
let textModel = Model.createFromString(lines.join('\n'));
|
||||
try {
|
||||
let actual = computeRanges(textModel, false, markers);
|
||||
// let r0 = r(1, 2);
|
||||
// let r1 = r(3, 12);
|
||||
// let r2 = r(4, 11);
|
||||
// let r3 = r(5, 6);
|
||||
// let r4 = r(9, 10);
|
||||
|
||||
assert.equal(actual.findRange(1), 0, '1');
|
||||
assert.equal(actual.findRange(2), 0, '2');
|
||||
assert.equal(actual.findRange(3), 1, '3');
|
||||
assert.equal(actual.findRange(4), 2, '4');
|
||||
assert.equal(actual.findRange(5), 3, '5');
|
||||
assert.equal(actual.findRange(6), 3, '6');
|
||||
assert.equal(actual.findRange(7), 2, '7');
|
||||
assert.equal(actual.findRange(8), 2, '8');
|
||||
assert.equal(actual.findRange(9), 4, '9');
|
||||
assert.equal(actual.findRange(10), 4, '10');
|
||||
assert.equal(actual.findRange(11), 2, '11');
|
||||
assert.equal(actual.findRange(12), 1, '12');
|
||||
assert.equal(actual.findRange(13), -1, '13');
|
||||
} finally {
|
||||
textModel.dispose();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
@@ -5,7 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { IntervalTree, IntervalNode } from 'vs/editor/common/model/intervalTree';
|
||||
import { IntervalTree, IntervalNode, getNodeColor, NodeColor, SENTINEL, intervalCompare } from 'vs/editor/common/model/intervalTree';
|
||||
|
||||
const GENERATE_TESTS = false;
|
||||
let TEST_COUNT = GENERATE_TESTS ? 10000 : 0;
|
||||
@@ -116,10 +116,10 @@ suite('IntervalTree', () => {
|
||||
}
|
||||
|
||||
if (PRINT_TREE) {
|
||||
this._tree.print();
|
||||
printTree(this._tree);
|
||||
}
|
||||
|
||||
this._tree.assertInvariants();
|
||||
assertTreeInvariants(this._tree);
|
||||
|
||||
let actual = this._tree.getAllInOrder().map(n => new Interval(n.cachedAbsoluteStart, n.cachedAbsoluteEnd));
|
||||
let expected = this._oracle.intervals;
|
||||
@@ -553,3 +553,89 @@ suite('IntervalTree', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function printTree(T: IntervalTree): void {
|
||||
if (T.root === SENTINEL) {
|
||||
console.log(`~~ empty`);
|
||||
return;
|
||||
}
|
||||
let out: string[] = [];
|
||||
_printTree(T, T.root, '', 0, out);
|
||||
console.log(out.join(''));
|
||||
}
|
||||
|
||||
function _printTree(T: IntervalTree, n: IntervalNode, indent: string, delta: number, out: string[]): void {
|
||||
out.push(`${indent}[${getNodeColor(n) === NodeColor.Red ? 'R' : 'B'},${n.delta}, ${n.start}->${n.end}, ${n.maxEnd}] : {${delta + n.start}->${delta + n.end}}, maxEnd: ${n.maxEnd + delta}\n`);
|
||||
if (n.left !== SENTINEL) {
|
||||
_printTree(T, n.left, indent + ' ', delta, out);
|
||||
} else {
|
||||
out.push(`${indent} NIL\n`);
|
||||
}
|
||||
if (n.right !== SENTINEL) {
|
||||
_printTree(T, n.right, indent + ' ', delta + n.delta, out);
|
||||
} else {
|
||||
out.push(`${indent} NIL\n`);
|
||||
}
|
||||
}
|
||||
|
||||
//#region Assertion
|
||||
|
||||
function assertTreeInvariants(T: IntervalTree): void {
|
||||
assert(getNodeColor(SENTINEL) === NodeColor.Black);
|
||||
assert(SENTINEL.parent === SENTINEL);
|
||||
assert(SENTINEL.left === SENTINEL);
|
||||
assert(SENTINEL.right === SENTINEL);
|
||||
assert(SENTINEL.start === 0);
|
||||
assert(SENTINEL.end === 0);
|
||||
assert(SENTINEL.delta === 0);
|
||||
assert(T.root.parent === SENTINEL);
|
||||
assertValidTree(T);
|
||||
}
|
||||
|
||||
function depth(n: IntervalNode): number {
|
||||
if (n === SENTINEL) {
|
||||
// The leafs are black
|
||||
return 1;
|
||||
}
|
||||
assert(depth(n.left) === depth(n.right));
|
||||
return (getNodeColor(n) === NodeColor.Black ? 1 : 0) + depth(n.left);
|
||||
}
|
||||
|
||||
function assertValidNode(n: IntervalNode, delta): void {
|
||||
if (n === SENTINEL) {
|
||||
return;
|
||||
}
|
||||
|
||||
let l = n.left;
|
||||
let r = n.right;
|
||||
|
||||
if (getNodeColor(n) === NodeColor.Red) {
|
||||
assert(getNodeColor(l) === NodeColor.Black);
|
||||
assert(getNodeColor(r) === NodeColor.Black);
|
||||
}
|
||||
|
||||
let expectedMaxEnd = n.end;
|
||||
if (l !== SENTINEL) {
|
||||
assert(intervalCompare(l.start + delta, l.end + delta, n.start + delta, n.end + delta) <= 0);
|
||||
expectedMaxEnd = Math.max(expectedMaxEnd, l.maxEnd);
|
||||
}
|
||||
if (r !== SENTINEL) {
|
||||
assert(intervalCompare(n.start + delta, n.end + delta, r.start + delta + n.delta, r.end + delta + n.delta) <= 0);
|
||||
expectedMaxEnd = Math.max(expectedMaxEnd, r.maxEnd + n.delta);
|
||||
}
|
||||
assert(n.maxEnd === expectedMaxEnd);
|
||||
|
||||
assertValidNode(l, delta);
|
||||
assertValidNode(r, delta + n.delta);
|
||||
}
|
||||
|
||||
function assertValidTree(T: IntervalTree): void {
|
||||
if (T.root === SENTINEL) {
|
||||
return;
|
||||
}
|
||||
assert(getNodeColor(T.root) === NodeColor.Black);
|
||||
assert(depth(T.root.left) === depth(T.root.right));
|
||||
assertValidNode(T.root, 0);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
@@ -11,7 +11,7 @@ import { MetadataConsts } from 'vs/editor/common/modes';
|
||||
import { ViewLineToken, ViewLineTokenFactory } from 'vs/editor/common/core/viewLineToken';
|
||||
|
||||
function assertLineTokens(_actual: LineTokens, _expected: TestToken[]): void {
|
||||
let expected = ViewLineTokenFactory.inflateArr(TestToken.toTokens(_expected), _actual.getLineLength());
|
||||
let expected = ViewLineTokenFactory.inflateArr(TestToken.toTokens(_expected), _actual.getLineContent().length);
|
||||
let actual = _actual.inflate();
|
||||
let decode = (token: ViewLineToken) => {
|
||||
return {
|
||||
@@ -1521,4 +1521,3 @@ suite('Editor Model - modelLine.append', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1154,7 +1154,6 @@ suite('deltaDecorations', () => {
|
||||
|
||||
assert.equal(initialIds.length, decorations.length, 'returns expected cnt of ids');
|
||||
assert.equal(initialIds.length, model.getAllDecorations().length, 'does not leak decorations');
|
||||
assert.equal(initialIds.length, model._getTrackedRangesCount(), 'does not leak tracked ranges');
|
||||
actualDecorations.sort((a, b) => strcmp(a.id, b.id));
|
||||
decorations.sort((a, b) => strcmp(a.id, b.id));
|
||||
assert.deepEqual(actualDecorations, decorations);
|
||||
@@ -1164,7 +1163,6 @@ suite('deltaDecorations', () => {
|
||||
|
||||
assert.equal(newIds.length, newDecorations.length, 'returns expected cnt of ids');
|
||||
assert.equal(newIds.length, model.getAllDecorations().length, 'does not leak decorations');
|
||||
assert.equal(newIds.length, model._getTrackedRangesCount(), 'does not leak tracked ranges');
|
||||
actualNewDecorations.sort((a, b) => strcmp(a.id, b.id));
|
||||
newDecorations.sort((a, b) => strcmp(a.id, b.id));
|
||||
assert.deepEqual(actualDecorations, decorations);
|
||||
|
||||
Reference in New Issue
Block a user