mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from master
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ITextBufferBuilder, ITextBufferFactory, ITextBuffer, DefaultEndOfLine } from 'vs/editor/common/model';
|
||||
import { DefaultEndOfLine, ITextBuffer, ITextBufferBuilder, ITextBufferFactory } from 'vs/editor/common/model';
|
||||
import { PieceTreeTextBufferBuilder } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder';
|
||||
|
||||
export function doBenchmark<T>(id: string, ts: T[], fn: (t: T) => void) {
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
require('../../../../../../bootstrap-amd').bootstrap('vs/editor/test/common/model/benchmark/entry');
|
||||
require('../../../../../../bootstrap-amd').load('vs/editor/test/common/model/benchmark/entry');
|
||||
@@ -2,7 +2,6 @@
|
||||
* 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 'vs/editor/test/common/model/benchmark/modelbuilder.benchmark';
|
||||
import 'vs/editor/test/common/model/benchmark/operations.benchmark';
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
* 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 { PieceTreeTextBufferBuilder } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder';
|
||||
import { ITextBufferBuilder } from 'vs/editor/common/model';
|
||||
import { generateRandomChunkWithLF } from 'vs/editor/test/common/model/linesTextBuffer/textBufferAutoTestUtils';
|
||||
import { PieceTreeTextBufferBuilder } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder';
|
||||
import { doBenchmark } from 'vs/editor/test/common/model/benchmark/benchmarkUtils';
|
||||
import { generateRandomChunkWithLF } from 'vs/editor/test/common/model/linesTextBuffer/textBufferAutoTestUtils';
|
||||
|
||||
let pieceTreeTextBufferBuilder = new PieceTreeTextBufferBuilder();
|
||||
let chunks: string[] = [];
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ITextBufferBuilder, EndOfLinePreference } from 'vs/editor/common/model';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { EndOfLinePreference, ITextBufferBuilder } from 'vs/editor/common/model';
|
||||
import { BenchmarkSuite } from 'vs/editor/test/common/model/benchmark/benchmarkUtils';
|
||||
import { generateRandomChunkWithLF, generateRandomEdits, generateSequentialInserts, getRandomInt } from 'vs/editor/test/common/model/linesTextBuffer/textBufferAutoTestUtils';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
|
||||
let fileSizes = [1, 1000, 64 * 1000, 32 * 1000 * 1000];
|
||||
let editTypes = [
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
* 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 { ITextBufferBuilder } from 'vs/editor/common/model';
|
||||
import { generateRandomReplaces, generateRandomChunkWithLF } from 'vs/editor/test/common/model/linesTextBuffer/textBufferAutoTestUtils';
|
||||
import { BenchmarkSuite } from 'vs/editor/test/common/model/benchmark/benchmarkUtils';
|
||||
import { generateRandomChunkWithLF, generateRandomReplaces } from 'vs/editor/test/common/model/linesTextBuffer/textBufferAutoTestUtils';
|
||||
|
||||
let fileSizes = [1, 1000, 64 * 1000, 32 * 1000 * 1000];
|
||||
|
||||
|
||||
@@ -3,15 +3,13 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { EndOfLineSequence, IIdentifiedSingleEditOperation, EndOfLinePreference } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { EndOfLinePreference, EndOfLineSequence, IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
|
||||
import { MirrorTextModel } from 'vs/editor/common/model/mirrorTextModel';
|
||||
import { assertSyncedModels, testApplyEditsWithSyncedModels } from 'vs/editor/test/common/model/editableTextModelTestUtils';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvents';
|
||||
import { assertSyncedModels, testApplyEditsWithSyncedModels } from 'vs/editor/test/common/model/editableTextModelTestUtils';
|
||||
|
||||
function createEditableTextModelFromString(text: string): TextModel {
|
||||
return new TextModel(text, TextModel.DEFAULT_CREATION_OPTIONS, null);
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
* 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 { CharCode } from 'vs/base/common/charCode';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
|
||||
import { testApplyEditsWithSyncedModels } from 'vs/editor/test/common/model/editableTextModelTestUtils';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
|
||||
const GENERATE_TESTS = false;
|
||||
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
* 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 { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { MirrorTextModel } from 'vs/editor/common/model/mirrorTextModel';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { EndOfLinePreference, EndOfLineSequence, IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
|
||||
import { MirrorTextModel } from 'vs/editor/common/model/mirrorTextModel';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvents';
|
||||
import { EndOfLinePreference, IIdentifiedSingleEditOperation, EndOfLineSequence } from 'vs/editor/common/model';
|
||||
|
||||
export function testApplyEditsWithSyncedModels(original: string[], edits: IIdentifiedSingleEditOperation[], expected: string[], inputEditsAreInvalid: boolean = false): void {
|
||||
let originalStr = original.join('\n');
|
||||
@@ -88,7 +87,7 @@ function assertLineMapping(model: TextModel, msg: string): void {
|
||||
}
|
||||
|
||||
|
||||
export function assertSyncedModels(text: string, callback: (model: TextModel, assertMirrorModels: () => void) => void, setup: (model: TextModel) => void = null): void {
|
||||
export function assertSyncedModels(text: string, callback: (model: TextModel, assertMirrorModels: () => void) => void, setup: ((model: TextModel) => void) | null = null): void {
|
||||
let model = new TextModel(text, TextModel.DEFAULT_CREATION_OPTIONS, null);
|
||||
model.setEOL(EndOfLineSequence.LF);
|
||||
assertLineMapping(model, 'model');
|
||||
@@ -98,7 +97,7 @@ export function assertSyncedModels(text: string, callback: (model: TextModel, as
|
||||
assertLineMapping(model, 'model');
|
||||
}
|
||||
|
||||
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) => {
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
* 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 { IntervalTree, IntervalNode, getNodeColor, NodeColor, SENTINEL, intervalCompare, setNodeStickiness, nodeAcceptEdit } from 'vs/editor/common/model/intervalTree';
|
||||
import { TrackedRangeStickiness } from 'vs/editor/common/model';
|
||||
import { IntervalNode, IntervalTree, NodeColor, SENTINEL, getNodeColor, intervalCompare, nodeAcceptEdit, setNodeStickiness } from 'vs/editor/common/model/intervalTree';
|
||||
|
||||
const GENERATE_TESTS = false;
|
||||
let TEST_COUNT = GENERATE_TESTS ? 10000 : 0;
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { PieceTreeTextBuffer, IValidatedEditOperation } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer';
|
||||
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
|
||||
import { DefaultEndOfLine } from 'vs/editor/common/model';
|
||||
import { IValidatedEditOperation, PieceTreeTextBuffer } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer';
|
||||
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
|
||||
|
||||
suite('PieceTreeTextBuffer._getInverseEdits', () => {
|
||||
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
* 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 { DefaultEndOfLine } from 'vs/editor/common/model';
|
||||
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { DefaultEndOfLine } from 'vs/editor/common/model';
|
||||
import { PieceTreeTextBuffer } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer';
|
||||
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
|
||||
|
||||
export function testTextBufferFactory(text: string, eol: string, mightContainNonBasicASCII: boolean, mightContainRTL: boolean): void {
|
||||
const textBuffer = <PieceTreeTextBuffer>createTextBufferFactory(text).create(DefaultEndOfLine.LF);
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
* 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 { CharCode } from 'vs/base/common/charCode';
|
||||
import { IIdentifiedSingleEditOperation, DefaultEndOfLine, ITextBufferBuilder, ITextBuffer } from 'vs/editor/common/model';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { DefaultEndOfLine, IIdentifiedSingleEditOperation, ITextBuffer, ITextBufferBuilder } from 'vs/editor/common/model';
|
||||
|
||||
export function getRandomInt(min: number, max: number): number {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
@@ -33,7 +32,7 @@ export function getRandomString(minLength: number, maxLength: number): string {
|
||||
}
|
||||
|
||||
export function generateRandomEdits(chunks: string[], editCnt: number): IIdentifiedSingleEditOperation[] {
|
||||
let lines = [];
|
||||
let lines: string[] = [];
|
||||
for (let i = 0; i < chunks.length; i++) {
|
||||
let newLines = chunks[i].split(/\r\n|\r|\n/);
|
||||
if (lines.length === 0) {
|
||||
@@ -66,7 +65,7 @@ export function generateRandomEdits(chunks: string[], editCnt: number): IIdentif
|
||||
}
|
||||
|
||||
export function generateSequentialInserts(chunks: string[], editCnt: number): IIdentifiedSingleEditOperation[] {
|
||||
let lines = [];
|
||||
let lines: string[] = [];
|
||||
for (let i = 0; i < chunks.length; i++) {
|
||||
let newLines = chunks[i].split(/\r\n|\r|\n/);
|
||||
if (lines.length === 0) {
|
||||
@@ -101,7 +100,7 @@ export function generateSequentialInserts(chunks: string[], editCnt: number): II
|
||||
}
|
||||
|
||||
export function generateRandomReplaces(chunks: string[], editCnt: number, searchStringLen: number, replaceStringLen: number): IIdentifiedSingleEditOperation[] {
|
||||
let lines = [];
|
||||
let lines: string[] = [];
|
||||
for (let i = 0; i < chunks.length; i++) {
|
||||
let newLines = chunks[i].split(/\r\n|\r|\n/);
|
||||
if (lines.length === 0) {
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
* 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 { LineTokens } from 'vs/editor/common/core/lineTokens';
|
||||
import { LanguageIdentifier, MetadataConsts } from 'vs/editor/common/modes';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ViewLineToken, ViewLineTokenFactory } from 'vs/editor/test/common/core/viewLineToken';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { LanguageIdentifier, MetadataConsts } from 'vs/editor/common/modes';
|
||||
import { ViewLineToken, ViewLineTokenFactory } from 'vs/editor/test/common/core/viewLineToken';
|
||||
|
||||
interface ILineEdit {
|
||||
startColumn: number;
|
||||
|
||||
@@ -2,17 +2,16 @@
|
||||
* 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 { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { TokenizationResult2 } from 'vs/editor/common/core/token';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { NULL_STATE } from 'vs/editor/common/modes/nullMode';
|
||||
import { TokenizationResult2 } from 'vs/editor/common/core/token';
|
||||
|
||||
// --------- utils
|
||||
|
||||
@@ -34,8 +33,8 @@ suite('Editor Model - Model Modes 1', () => {
|
||||
}
|
||||
};
|
||||
|
||||
let thisModel: TextModel = null;
|
||||
let languageRegistration: IDisposable = null;
|
||||
let thisModel: TextModel | null = null;
|
||||
let languageRegistration: IDisposable | null = null;
|
||||
|
||||
setup(() => {
|
||||
const TEXT =
|
||||
@@ -204,8 +203,8 @@ suite('Editor Model - Model Modes 2', () => {
|
||||
stateEqual((<any>model)._tokens._lastState, states[len]);
|
||||
}
|
||||
|
||||
let thisModel: TextModel = null;
|
||||
let languageRegistration: IDisposable = null;
|
||||
let thisModel: TextModel | null = null;
|
||||
let languageRegistration: IDisposable | null = null;
|
||||
|
||||
setup(() => {
|
||||
const TEXT =
|
||||
|
||||
@@ -2,23 +2,19 @@
|
||||
* 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 { Disposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import {
|
||||
ModelRawContentChangedEvent, ModelRawFlush, ModelRawLineChanged,
|
||||
ModelRawLinesDeleted, ModelRawLinesInserted
|
||||
} from 'vs/editor/common/model/textModelEvents';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { LanguageIdentifier, TokenizationRegistry, IState, MetadataConsts } from 'vs/editor/common/modes';
|
||||
import { MockMode } from 'vs/editor/test/common/mocks/mockMode';
|
||||
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import { TokenizationResult2 } from 'vs/editor/common/core/token';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { ModelRawContentChangedEvent, ModelRawFlush, ModelRawLineChanged, ModelRawLinesDeleted, ModelRawLinesInserted } from 'vs/editor/common/model/textModelEvents';
|
||||
import { IState, LanguageIdentifier, MetadataConsts, TokenizationRegistry } from 'vs/editor/common/modes';
|
||||
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import { NULL_STATE } from 'vs/editor/common/modes/nullMode';
|
||||
import { dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { MockMode } from 'vs/editor/test/common/mocks/mockMode';
|
||||
|
||||
// --------- utils
|
||||
|
||||
@@ -106,7 +102,7 @@ suite('Editor Model - Model', () => {
|
||||
});
|
||||
|
||||
test('model insert text without newline eventing', () => {
|
||||
let e: ModelRawContentChangedEvent = null;
|
||||
let e: ModelRawContentChangedEvent | null = null;
|
||||
thisModel.onDidChangeRawContent((_e) => {
|
||||
if (e !== null) {
|
||||
assert.fail('Unexpected assertion error');
|
||||
@@ -125,7 +121,7 @@ suite('Editor Model - Model', () => {
|
||||
});
|
||||
|
||||
test('model insert text with one newline eventing', () => {
|
||||
let e: ModelRawContentChangedEvent = null;
|
||||
let e: ModelRawContentChangedEvent | null = null;
|
||||
thisModel.onDidChangeRawContent((_e) => {
|
||||
if (e !== null) {
|
||||
assert.fail('Unexpected assertion error');
|
||||
@@ -202,7 +198,7 @@ suite('Editor Model - Model', () => {
|
||||
});
|
||||
|
||||
test('model delete text from one line eventing', () => {
|
||||
let e: ModelRawContentChangedEvent = null;
|
||||
let e: ModelRawContentChangedEvent | null = null;
|
||||
thisModel.onDidChangeRawContent((_e) => {
|
||||
if (e !== null) {
|
||||
assert.fail('Unexpected assertion error');
|
||||
@@ -221,7 +217,7 @@ suite('Editor Model - Model', () => {
|
||||
});
|
||||
|
||||
test('model delete all text from a line eventing', () => {
|
||||
let e: ModelRawContentChangedEvent = null;
|
||||
let e: ModelRawContentChangedEvent | null = null;
|
||||
thisModel.onDidChangeRawContent((_e) => {
|
||||
if (e !== null) {
|
||||
assert.fail('Unexpected assertion error');
|
||||
@@ -240,7 +236,7 @@ suite('Editor Model - Model', () => {
|
||||
});
|
||||
|
||||
test('model delete text from two lines eventing', () => {
|
||||
let e: ModelRawContentChangedEvent = null;
|
||||
let e: ModelRawContentChangedEvent | null = null;
|
||||
thisModel.onDidChangeRawContent((_e) => {
|
||||
if (e !== null) {
|
||||
assert.fail('Unexpected assertion error');
|
||||
@@ -260,7 +256,7 @@ suite('Editor Model - Model', () => {
|
||||
});
|
||||
|
||||
test('model delete text from many lines eventing', () => {
|
||||
let e: ModelRawContentChangedEvent = null;
|
||||
let e: ModelRawContentChangedEvent | null = null;
|
||||
thisModel.onDidChangeRawContent((_e) => {
|
||||
if (e !== null) {
|
||||
assert.fail('Unexpected assertion error');
|
||||
@@ -311,7 +307,7 @@ suite('Editor Model - Model', () => {
|
||||
|
||||
// --------- setValue
|
||||
test('setValue eventing', () => {
|
||||
let e: ModelRawContentChangedEvent = null;
|
||||
let e: ModelRawContentChangedEvent | null = null;
|
||||
thisModel.onDidChangeRawContent((_e) => {
|
||||
if (e !== null) {
|
||||
assert.fail('Unexpected assertion error');
|
||||
@@ -394,7 +390,7 @@ suite('Editor Model - Words', () => {
|
||||
tokenize: undefined,
|
||||
tokenize2: (line: string, state: IState): TokenizationResult2 => {
|
||||
const tokensArr: number[] = [];
|
||||
let prevLanguageId: LanguageIdentifier = undefined;
|
||||
let prevLanguageId: LanguageIdentifier | undefined = undefined;
|
||||
for (let i = 0; i < line.length; i++) {
|
||||
const languageId = (line.charAt(i) === 'x' ? INNER_LANGUAGE_ID : OUTER_LANGUAGE_ID);
|
||||
if (prevLanguageId !== languageId) {
|
||||
@@ -466,4 +462,30 @@ suite('Editor Model - Words', () => {
|
||||
assert.deepEqual(model.getWordAtPosition(new Position(1, 6)), { word: 'xx', startColumn: 4, endColumn: 6 });
|
||||
assert.deepEqual(model.getWordAtPosition(new Position(1, 7)), { word: 'ab', startColumn: 7, endColumn: 9 });
|
||||
});
|
||||
|
||||
test('issue #61296: VS code freezes when editing CSS file with emoji', () => {
|
||||
const MODE_ID = new LanguageIdentifier('testMode', 4);
|
||||
|
||||
const mode = new class extends MockMode {
|
||||
constructor() {
|
||||
super(MODE_ID);
|
||||
this._register(LanguageConfigurationRegistry.register(this.getLanguageIdentifier(), {
|
||||
wordPattern: /(#?-?\d*\.\d\w*%?)|(::?[\w-]*(?=[^,{;]*[,{]))|(([@#.!])?[\w-?]+%?|[@#!.])/g
|
||||
}));
|
||||
}
|
||||
};
|
||||
disposables.push(mode);
|
||||
|
||||
const thisModel = TextModel.createFromString('.🐷-a-b', undefined, MODE_ID);
|
||||
disposables.push(thisModel);
|
||||
|
||||
assert.deepEqual(thisModel.getWordAtPosition(new Position(1, 1)), { word: '.', startColumn: 1, endColumn: 2 });
|
||||
assert.deepEqual(thisModel.getWordAtPosition(new Position(1, 2)), { word: '.', startColumn: 1, endColumn: 2 });
|
||||
assert.deepEqual(thisModel.getWordAtPosition(new Position(1, 3)), null);
|
||||
assert.deepEqual(thisModel.getWordAtPosition(new Position(1, 4)), { word: '-a-b', startColumn: 4, endColumn: 8 });
|
||||
assert.deepEqual(thisModel.getWordAtPosition(new Position(1, 5)), { word: '-a-b', startColumn: 4, endColumn: 8 });
|
||||
assert.deepEqual(thisModel.getWordAtPosition(new Position(1, 6)), { word: '-a-b', startColumn: 4, endColumn: 8 });
|
||||
assert.deepEqual(thisModel.getWordAtPosition(new Position(1, 7)), { word: '-a-b', startColumn: 4, endColumn: 8 });
|
||||
assert.deepEqual(thisModel.getWordAtPosition(new Position(1, 8)), { word: '-a-b', startColumn: 4, endColumn: 8 });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
* 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 { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { IModelDeltaDecoration, TrackedRangeStickiness, EndOfLineSequence } from 'vs/editor/common/model';
|
||||
import { EndOfLineSequence, IModelDeltaDecoration, TrackedRangeStickiness } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
|
||||
// --------- utils
|
||||
@@ -51,7 +50,7 @@ function addDecoration(model: TextModel, startLineNumber: number, startColumn: n
|
||||
}
|
||||
|
||||
function lineHasDecorations(model: TextModel, lineNumber: number, decorations: { start: number; end: number; className: string; }[]) {
|
||||
let lineDecorations = [];
|
||||
let lineDecorations: Array<{ start: number; end: number; className: string; }> = [];
|
||||
let decs = model.getLineDecorations(lineNumber);
|
||||
for (let i = 0, len = decs.length; i < len; i++) {
|
||||
lineDecorations.push({
|
||||
@@ -1370,4 +1369,22 @@ suite('deltaDecorations', () => {
|
||||
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('issue #41492: URL highlighting persists after pasting over url', () => {
|
||||
|
||||
let model = TextModel.createFromString([
|
||||
'My First Line'
|
||||
].join('\n'));
|
||||
|
||||
const id = model.deltaDecorations([], [{ range: new Range(1, 2, 1, 14), options: { stickiness: TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges, collapseOnReplaceEdit: true } }])[0];
|
||||
model.applyEdits([{
|
||||
range: new Range(1, 1, 1, 14),
|
||||
text: 'Some new text that is longer than the previous one',
|
||||
forceMoveMarkers: false
|
||||
}]);
|
||||
const actual = model.getDecorationRange(id);
|
||||
assert.deepEqual(actual, new Range(1, 1, 1, 1));
|
||||
|
||||
model.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
* 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 { Range } from 'vs/editor/common/core/range';
|
||||
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
|
||||
|
||||
@@ -2,20 +2,19 @@
|
||||
* 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 { WordCharacterClassifier } from 'vs/editor/common/controller/wordCharacterClassifier';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { PieceTreeTextBufferBuilder } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder';
|
||||
import { DefaultEndOfLine } from 'vs/editor/common/model';
|
||||
import { PieceTreeBase } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase';
|
||||
import { SENTINEL, NodeColor, TreeNode } from 'vs/editor/common/model/pieceTreeTextBuffer/rbTreeBase';
|
||||
import { PieceTreeTextBuffer } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer';
|
||||
import { PieceTreeTextBufferBuilder } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder';
|
||||
import { NodeColor, SENTINEL, TreeNode } from 'vs/editor/common/model/pieceTreeTextBuffer/rbTreeBase';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { ITextSnapshot } from 'vs/platform/files/common/files';
|
||||
import { SearchData } from 'vs/editor/common/model/textModelSearch';
|
||||
import { WordCharacterClassifier } from 'vs/editor/common/controller/wordCharacterClassifier';
|
||||
import { ITextSnapshot } from 'vs/platform/files/common/files';
|
||||
|
||||
const alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n';
|
||||
|
||||
@@ -1517,7 +1516,7 @@ suite('random is unsupervised', () => {
|
||||
|
||||
test('random chunks', function () {
|
||||
this.timeout(500000);
|
||||
let chunks = [];
|
||||
let chunks: string[] = [];
|
||||
for (let i = 0; i < 5; i++) {
|
||||
chunks.push(randomStr(1000));
|
||||
}
|
||||
@@ -1552,7 +1551,7 @@ suite('random is unsupervised', () => {
|
||||
|
||||
test('random chunks 2', function () {
|
||||
this.timeout(500000);
|
||||
let chunks = [];
|
||||
let chunks: string[] = [];
|
||||
chunks.push(randomStr(1000));
|
||||
|
||||
let pieceTable = createTextBuffer(chunks, false);
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
* 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 { UTF8_BOM_CHARACTER } from 'vs/base/common/strings';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { TextModel, createTextBuffer } from 'vs/editor/common/model/textModel';
|
||||
import { UTF8_BOM_CHARACTER } from 'vs/base/common/strings';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
function testGuessIndentation(defaultInsertSpaces: boolean, defaultTabSize: number, expectedInsertSpaces: boolean, expectedTabSize: number, text: string[], msg?: string): void {
|
||||
@@ -315,7 +314,7 @@ suite('Editor Model - TextModel', () => {
|
||||
' ',
|
||||
' ',
|
||||
], 'whitespace lines don\'t count');
|
||||
assertGuess(true, 4, [
|
||||
assertGuess(true, 3, [
|
||||
'x',
|
||||
' x',
|
||||
' x',
|
||||
@@ -328,8 +327,8 @@ suite('Editor Model - TextModel', () => {
|
||||
' x',
|
||||
' x',
|
||||
' x',
|
||||
], 'odd number is not allowed: 6x3, 3x4');
|
||||
assertGuess(true, 4, [
|
||||
], '6x3, 3x4');
|
||||
assertGuess(true, 5, [
|
||||
'x',
|
||||
' x',
|
||||
' x',
|
||||
@@ -342,8 +341,12 @@ suite('Editor Model - TextModel', () => {
|
||||
' x',
|
||||
' x',
|
||||
' x',
|
||||
], 'odd number is not allowed: 6x5, 3x4');
|
||||
assertGuess(true, 4, [
|
||||
], '6x5, 3x4');
|
||||
assertGuess(true, 7, [
|
||||
'x',
|
||||
' x',
|
||||
' x',
|
||||
' x',
|
||||
'x',
|
||||
' x',
|
||||
' x',
|
||||
@@ -352,11 +355,7 @@ suite('Editor Model - TextModel', () => {
|
||||
' x',
|
||||
' x',
|
||||
' x',
|
||||
'x',
|
||||
' x',
|
||||
' x',
|
||||
' x',
|
||||
], 'odd number is not allowed: 6x7, 3x4');
|
||||
], '6x7, 1x5, 2x4');
|
||||
assertGuess(true, 2, [
|
||||
'x',
|
||||
' x',
|
||||
@@ -508,7 +507,7 @@ suite('Editor Model - TextModel', () => {
|
||||
' x',
|
||||
' x',
|
||||
], '6x4, 2x5, 4x8');
|
||||
assertGuess(true, undefined, [
|
||||
assertGuess(true, 3, [
|
||||
'x',
|
||||
' x',
|
||||
' x',
|
||||
@@ -550,6 +549,32 @@ suite('Editor Model - TextModel', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('issue #55818: Broken indentation detection', () => {
|
||||
assertGuess(true, 2, [
|
||||
'',
|
||||
'/* REQUIRE */',
|
||||
'',
|
||||
'const foo = require ( \'foo\' ),',
|
||||
' bar = require ( \'bar\' );',
|
||||
'',
|
||||
'/* MY FN */',
|
||||
'',
|
||||
'function myFn () {',
|
||||
'',
|
||||
' const asd = 1,',
|
||||
' dsa = 2;',
|
||||
'',
|
||||
' return bar ( foo ( asd ) );',
|
||||
'',
|
||||
'}',
|
||||
'',
|
||||
'/* EXPORT */',
|
||||
'',
|
||||
'module.exports = myFn;',
|
||||
'',
|
||||
]);
|
||||
});
|
||||
|
||||
test('validatePosition', () => {
|
||||
|
||||
let m = TextModel.createFromString('line one\nline two');
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
* 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 { Position } from 'vs/editor/common/core/position';
|
||||
import { FindMatch, EndOfLineSequence } from 'vs/editor/common/model';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { TextModelSearch, SearchParams, SearchData } from 'vs/editor/common/model/textModelSearch';
|
||||
import { getMapForWordSeparators } from 'vs/editor/common/controller/wordCharacterClassifier';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { EndOfLineSequence, FindMatch } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { SearchData, SearchParams, TextModelSearch, isMultilineRegexSource } from 'vs/editor/common/model/textModelSearch';
|
||||
import { USUAL_WORD_SEPARATORS } from 'vs/editor/common/model/wordHelper';
|
||||
|
||||
// --------- Find
|
||||
@@ -18,7 +17,7 @@ suite('TextModelSearch', () => {
|
||||
|
||||
const usualWordSeparators = getMapForWordSeparators(USUAL_WORD_SEPARATORS);
|
||||
|
||||
function assertFindMatch(actual: FindMatch, expectedRange: Range, expectedMatches: string[] = null): void {
|
||||
function assertFindMatch(actual: FindMatch, expectedRange: Range, expectedMatches: string[] | null = null): void {
|
||||
assert.deepEqual(actual, new FindMatch(expectedRange, expectedMatches));
|
||||
}
|
||||
|
||||
@@ -633,4 +632,106 @@ suite('TextModelSearch', () => {
|
||||
assertParseSearchResult('foo\\r', true, false, null, new SearchData(/foo\r/gim, null, null));
|
||||
assertParseSearchResult('foo\\\\r', true, false, null, new SearchData(/foo\\r/gi, null, null));
|
||||
});
|
||||
|
||||
test('issue #53415. \W should match line break.', () => {
|
||||
assertFindMatches(
|
||||
[
|
||||
'text',
|
||||
'180702-',
|
||||
'180703-180704'
|
||||
].join('\n'),
|
||||
'\\d{6}-\\W', true, false, null,
|
||||
[
|
||||
[2, 1, 3, 1]
|
||||
]
|
||||
);
|
||||
|
||||
assertFindMatches(
|
||||
[
|
||||
'Just some text',
|
||||
'',
|
||||
'Just'
|
||||
].join('\n'),
|
||||
'\\W', true, false, null,
|
||||
[
|
||||
[1, 5, 1, 6],
|
||||
[1, 10, 1, 11],
|
||||
[1, 15, 2, 1],
|
||||
[2, 1, 3, 1]
|
||||
]
|
||||
);
|
||||
|
||||
// Line break doesn't affect the result as we always use \n as line break when doing search
|
||||
assertFindMatches(
|
||||
[
|
||||
'Just some text',
|
||||
'',
|
||||
'Just'
|
||||
].join('\r\n'),
|
||||
'\\W', true, false, null,
|
||||
[
|
||||
[1, 5, 1, 6],
|
||||
[1, 10, 1, 11],
|
||||
[1, 15, 2, 1],
|
||||
[2, 1, 3, 1]
|
||||
]
|
||||
);
|
||||
|
||||
assertFindMatches(
|
||||
[
|
||||
'Just some text',
|
||||
'\tJust',
|
||||
'Just'
|
||||
].join('\n'),
|
||||
'\\W', true, false, null,
|
||||
[
|
||||
[1, 5, 1, 6],
|
||||
[1, 10, 1, 11],
|
||||
[1, 15, 2, 1],
|
||||
[2, 1, 2, 2],
|
||||
[2, 6, 3, 1],
|
||||
]
|
||||
);
|
||||
|
||||
// line break is seen as one non-word character
|
||||
assertFindMatches(
|
||||
[
|
||||
'Just some text',
|
||||
'',
|
||||
'Just'
|
||||
].join('\n'),
|
||||
'\\W{2}', true, false, null,
|
||||
[
|
||||
[1, 5, 1, 7],
|
||||
[1, 16, 3, 1]
|
||||
]
|
||||
);
|
||||
|
||||
// even if it's \r\n
|
||||
assertFindMatches(
|
||||
[
|
||||
'Just some text',
|
||||
'',
|
||||
'Just'
|
||||
].join('\r\n'),
|
||||
'\\W{2}', true, false, null,
|
||||
[
|
||||
[1, 5, 1, 7],
|
||||
[1, 16, 3, 1]
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
test('isMultilineRegexSource', () => {
|
||||
assert(!isMultilineRegexSource('foo'));
|
||||
assert(!isMultilineRegexSource(''));
|
||||
assert(!isMultilineRegexSource('foo\\sbar'));
|
||||
assert(!isMultilineRegexSource('\\\\notnewline'));
|
||||
|
||||
assert(isMultilineRegexSource('foo\\nbar'));
|
||||
assert(isMultilineRegexSource('foo\\nbar\\s'));
|
||||
assert(isMultilineRegexSource('foo\\r\\n'));
|
||||
assert(isMultilineRegexSource('\\n'));
|
||||
assert(isMultilineRegexSource('foo\\W'));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,20 +2,19 @@
|
||||
* 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 { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { ViewLineToken } from 'vs/editor/test/common/core/viewLineToken';
|
||||
import { ITokenizationSupport, TokenizationRegistry, LanguageId, LanguageIdentifier, MetadataConsts } from 'vs/editor/common/modes';
|
||||
import { CharacterPair } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { TokenizationResult2 } from 'vs/editor/common/core/token';
|
||||
import { IFoundBracket } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { ITokenizationSupport, LanguageId, LanguageIdentifier, MetadataConsts, TokenizationRegistry } from 'vs/editor/common/modes';
|
||||
import { CharacterPair } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import { NULL_STATE } from 'vs/editor/common/modes/nullMode';
|
||||
import { TokenizationResult2 } from 'vs/editor/common/core/token';
|
||||
import { ViewLineToken } from 'vs/editor/test/common/core/viewLineToken';
|
||||
|
||||
suite('TextModelWithTokens', () => {
|
||||
|
||||
@@ -159,7 +158,7 @@ suite('TextModelWithTokens - bracket matching', () => {
|
||||
}
|
||||
|
||||
const languageIdentifier = new LanguageIdentifier('bracketMode1', LanguageId.PlainText);
|
||||
let registration: IDisposable = null;
|
||||
let registration: IDisposable | null = null;
|
||||
|
||||
setup(() => {
|
||||
registration = LanguageConfigurationRegistry.register(languageIdentifier, {
|
||||
@@ -391,6 +390,34 @@ suite('TextModelWithTokens regression tests', () => {
|
||||
model.dispose();
|
||||
registration.dispose();
|
||||
});
|
||||
|
||||
test('issue #63822: Wrong embedded language detected for empty lines', () => {
|
||||
const outerMode = new LanguageIdentifier('outerMode', 3);
|
||||
const innerMode = new LanguageIdentifier('innerMode', 4);
|
||||
|
||||
const tokenizationSupport: ITokenizationSupport = {
|
||||
getInitialState: () => NULL_STATE,
|
||||
tokenize: undefined,
|
||||
tokenize2: (line, state) => {
|
||||
let tokens = new Uint32Array(2);
|
||||
tokens[0] = 0;
|
||||
tokens[1] = (
|
||||
innerMode.id << MetadataConsts.LANGUAGEID_OFFSET
|
||||
) >>> 0;
|
||||
return new TokenizationResult2(tokens, state);
|
||||
}
|
||||
};
|
||||
|
||||
let registration = TokenizationRegistry.register(outerMode.language, tokenizationSupport);
|
||||
|
||||
let model = TextModel.createFromString('A model with one line', undefined, outerMode);
|
||||
|
||||
model.forceTokenization(1);
|
||||
assert.equal(model.getLanguageIdAtPosition(1, 1), innerMode.id);
|
||||
|
||||
model.dispose();
|
||||
registration.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
suite('TextModel.getLineIndentGuide', () => {
|
||||
|
||||
Reference in New Issue
Block a user