mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Merge from vscode 33a65245075e4d18908652865a79cf5489c30f40 (#9279)
* Merge from vscode 33a65245075e4d18908652865a79cf5489c30f40 * remove github
This commit is contained in:
@@ -10,7 +10,7 @@ import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl';
|
||||
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration';
|
||||
@@ -199,7 +199,7 @@ suite('SideEditing', () => {
|
||||
];
|
||||
|
||||
function _runTest(selection: Selection, editRange: Range, editText: string, editForceMoveMarkers: boolean, expected: Selection, msg: string): void {
|
||||
const model = TextModel.createFromString(LINES.join('\n'));
|
||||
const model = createTextModel(LINES.join('\n'));
|
||||
const config = new TestConfiguration({});
|
||||
const monospaceLineBreaksComputerFactory = MonospaceLineBreaksComputerFactory.create(config.options);
|
||||
const viewModel = new ViewModel(0, config, model, monospaceLineBreaksComputerFactory, monospaceLineBreaksComputerFactory, null!);
|
||||
|
||||
@@ -5551,4 +5551,28 @@ suite('Undo stops', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('can undo typing and EOL change in one undo stop', () => {
|
||||
let model = createTextModel(
|
||||
[
|
||||
'A line',
|
||||
'Another line',
|
||||
].join('\n')
|
||||
);
|
||||
|
||||
withTestCodeEditor(null, { model: model }, (editor, cursor) => {
|
||||
cursor.setSelections('test', [new Selection(1, 3, 1, 3)]);
|
||||
cursorCommand(cursor, H.Type, { text: 'first' }, 'keyboard');
|
||||
assert.equal(model.getValue(), 'A first line\nAnother line');
|
||||
assertCursor(cursor, new Selection(1, 8, 1, 8));
|
||||
|
||||
model.pushEOL(EndOfLineSequence.CRLF);
|
||||
assert.equal(model.getValue(), 'A first line\r\nAnother line');
|
||||
assertCursor(cursor, new Selection(1, 8, 1, 8));
|
||||
|
||||
CoreEditingCommands.Undo.runEditorCommand(null, editor, null);
|
||||
assert.equal(model.getValue(), 'A line\nAnother line');
|
||||
assertCursor(cursor, new Selection(1, 3, 1, 3));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@ import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl';
|
||||
import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration';
|
||||
import { MonospaceLineBreaksComputerFactory } from 'vs/editor/common/viewModel/monospaceLineBreaksComputer';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
suite('Cursor move command test', () => {
|
||||
|
||||
@@ -31,7 +32,7 @@ suite('Cursor move command test', () => {
|
||||
'1'
|
||||
].join('\n');
|
||||
|
||||
thisModel = TextModel.createFromString(text);
|
||||
thisModel = createTextModel(text);
|
||||
thisConfiguration = new TestConfiguration({});
|
||||
const monospaceLineBreaksComputerFactory = MonospaceLineBreaksComputerFactory.create(thisConfiguration.options);
|
||||
thisViewModel = new ViewModel(0, thisConfiguration, thisModel, monospaceLineBreaksComputerFactory, monospaceLineBreaksComputerFactory, null!);
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ITextAreaWrapper, PagedScreenReaderStrategy, TextAreaState } from 'vs/editor/browser/controller/textAreaState';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
export class MockTextAreaWrapper extends Disposable implements ITextAreaWrapper {
|
||||
|
||||
@@ -506,7 +506,7 @@ suite('TextAreaState', () => {
|
||||
suite('PagedScreenReaderStrategy', () => {
|
||||
|
||||
function testPagedScreenReaderStrategy(lines: string[], selection: Selection, expected: TextAreaState): void {
|
||||
const model = TextModel.createFromString(lines.join('\n'));
|
||||
const model = createTextModel(lines.join('\n'));
|
||||
const actual = PagedScreenReaderStrategy.fromEditorSelection(TextAreaState.EMPTY, model, selection, 10, true);
|
||||
assert.ok(equalsTextAreaState(actual, expected));
|
||||
model.dispose();
|
||||
|
||||
@@ -11,7 +11,7 @@ import * as editorOptions from 'vs/editor/common/config/editorOptions';
|
||||
import { Cursor } from 'vs/editor/common/controller/cursor';
|
||||
import { IConfiguration, IEditorContribution } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl';
|
||||
import { TestCodeEditorService, TestCommandService } from 'vs/editor/test/browser/editorTestServices';
|
||||
import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration';
|
||||
@@ -77,9 +77,9 @@ export function withTestCodeEditor(text: string | string[] | null, options: Test
|
||||
// create a model if necessary and remember it in order to dispose it.
|
||||
if (!options.model) {
|
||||
if (typeof text === 'string') {
|
||||
options.model = TextModel.createFromString(text);
|
||||
options.model = createTextModel(text);
|
||||
} else if (text) {
|
||||
options.model = TextModel.createFromString(text.join('\n'));
|
||||
options.model = createTextModel(text.join('\n'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { IRange } from 'vs/editor/common/core/range';
|
||||
import { Selection, ISelection } from 'vs/editor/common/core/selection';
|
||||
import { ICommand, Handler, IEditOperationBuilder } from 'vs/editor/common/editorCommon';
|
||||
import { IIdentifiedSingleEditOperation, ITextModel } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
import { LanguageIdentifier } from 'vs/editor/common/modes';
|
||||
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
|
||||
@@ -21,7 +21,7 @@ export function testCommand(
|
||||
expectedSelection: Selection,
|
||||
forceTokenization?: boolean
|
||||
): void {
|
||||
let model = TextModel.createFromString(lines.join('\n'), undefined, languageIdentifier);
|
||||
let model = createTextModel(lines.join('\n'), undefined, languageIdentifier);
|
||||
withTestCodeEditor('', { model: model }, (_editor, cursor) => {
|
||||
if (!cursor) {
|
||||
return;
|
||||
|
||||
@@ -7,9 +7,12 @@ import { URI } from 'vs/base/common/uri';
|
||||
import { DefaultEndOfLine, ITextModelCreationOptions } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { LanguageIdentifier } from 'vs/editor/common/modes';
|
||||
import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService';
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
|
||||
|
||||
export function withEditorModel(text: string[], callback: (model: TextModel) => void): void {
|
||||
let model = TextModel.createFromString(text.join('\n'));
|
||||
let model = createTextModel(text.join('\n'));
|
||||
callback(model);
|
||||
model.dispose();
|
||||
}
|
||||
@@ -36,5 +39,8 @@ export function createTextModel(text: string, _options: IRelaxedTextModelCreatio
|
||||
isForSimpleWidget: (typeof _options.isForSimpleWidget === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.isForSimpleWidget : _options.isForSimpleWidget),
|
||||
largeFileOptimizations: (typeof _options.largeFileOptimizations === 'undefined' ? TextModel.DEFAULT_CREATION_OPTIONS.largeFileOptimizations : _options.largeFileOptimizations),
|
||||
};
|
||||
return TextModel.createFromString(text, options, languageIdentifier, uri);
|
||||
const dialogService = new TestDialogService();
|
||||
const notificationService = new TestNotificationService();
|
||||
const undoRedoService = new UndoRedoService(dialogService, notificationService);
|
||||
return new TextModel(text, options, languageIdentifier, uri, undoRedoService);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,10 @@ 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 { assertSyncedModels, testApplyEditsWithSyncedModels } from 'vs/editor/test/common/model/editableTextModelTestUtils';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
function createEditableTextModelFromString(text: string): TextModel {
|
||||
return TextModel.createFromString(text, TextModel.DEFAULT_CREATION_OPTIONS, null);
|
||||
return createTextModel(text, TextModel.DEFAULT_CREATION_OPTIONS, null);
|
||||
}
|
||||
|
||||
suite('EditorModel - EditableTextModel.applyEdits updates mightContainRTL', () => {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { EndOfLinePreference, EndOfLineSequence, IIdentifiedSingleEditOperation
|
||||
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 { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
export function testApplyEditsWithSyncedModels(original: string[], edits: IIdentifiedSingleEditOperation[], expected: string[], inputEditsAreInvalid: boolean = false): void {
|
||||
let originalStr = original.join('\n');
|
||||
@@ -88,7 +89,7 @@ function assertLineMapping(model: TextModel, msg: string): void {
|
||||
|
||||
|
||||
export function assertSyncedModels(text: string, callback: (model: TextModel, assertMirrorModels: () => void) => void, setup: ((model: TextModel) => void) | null = null): void {
|
||||
let model = TextModel.createFromString(text, TextModel.DEFAULT_CREATION_OPTIONS, null);
|
||||
let model = createTextModel(text, TextModel.DEFAULT_CREATION_OPTIONS, null);
|
||||
model.setEOL(EndOfLineSequence.LF);
|
||||
assertLineMapping(model, 'model');
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Range } from 'vs/editor/common/core/range';
|
||||
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';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
interface ILineEdit {
|
||||
startColumn: number;
|
||||
@@ -106,7 +107,7 @@ suite('ModelLinesTokens', () => {
|
||||
|
||||
function testApplyEdits(initial: IBufferLineState[], edits: IEdit[], expected: IBufferLineState[]): void {
|
||||
const initialText = initial.map(el => el.text).join('\n');
|
||||
const model = TextModel.createFromString(initialText, TextModel.DEFAULT_CREATION_OPTIONS, new LanguageIdentifier('test', 0));
|
||||
const model = createTextModel(initialText, TextModel.DEFAULT_CREATION_OPTIONS, new LanguageIdentifier('test', 0));
|
||||
for (let lineIndex = 0; lineIndex < initial.length; lineIndex++) {
|
||||
const lineTokens = initial[lineIndex].tokens;
|
||||
const lineTextLength = model.getLineMaxColumn(lineIndex + 1) - 1;
|
||||
@@ -442,7 +443,7 @@ suite('ModelLinesTokens', () => {
|
||||
}
|
||||
|
||||
test('insertion on empty line', () => {
|
||||
const model = TextModel.createFromString('some text', TextModel.DEFAULT_CREATION_OPTIONS, new LanguageIdentifier('test', 0));
|
||||
const model = createTextModel('some text', TextModel.DEFAULT_CREATION_OPTIONS, new LanguageIdentifier('test', 0));
|
||||
const tokens = TestToken.toTokens([new TestToken(0, 1)]);
|
||||
LineTokens.convertToEndOffset(tokens, model.getLineMaxColumn(1) - 1);
|
||||
model.setLineTokens(1, tokens);
|
||||
|
||||
@@ -12,6 +12,7 @@ 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 { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
// --------- utils
|
||||
|
||||
@@ -46,7 +47,7 @@ suite('Editor Model - Model Modes 1', () => {
|
||||
const LANGUAGE_ID = 'modelModeTest1';
|
||||
calledFor = [];
|
||||
languageRegistration = modes.TokenizationRegistry.register(LANGUAGE_ID, tokenizationSupport);
|
||||
thisModel = TextModel.createFromString(TEXT, undefined, new modes.LanguageIdentifier(LANGUAGE_ID, 0));
|
||||
thisModel = createTextModel(TEXT, undefined, new modes.LanguageIdentifier(LANGUAGE_ID, 0));
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -199,7 +200,7 @@ suite('Editor Model - Model Modes 2', () => {
|
||||
'Line5';
|
||||
const LANGUAGE_ID = 'modelModeTest2';
|
||||
languageRegistration = modes.TokenizationRegistry.register(LANGUAGE_ID, tokenizationSupport);
|
||||
thisModel = TextModel.createFromString(TEXT, undefined, new modes.LanguageIdentifier(LANGUAGE_ID, 0));
|
||||
thisModel = createTextModel(TEXT, undefined, new modes.LanguageIdentifier(LANGUAGE_ID, 0));
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
|
||||
@@ -15,6 +15,7 @@ import { IState, LanguageIdentifier, MetadataConsts, TokenizationRegistry } from
|
||||
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import { NULL_STATE } from 'vs/editor/common/modes/nullMode';
|
||||
import { MockMode } from 'vs/editor/test/common/mocks/mockMode';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
// --------- utils
|
||||
|
||||
@@ -35,7 +36,7 @@ suite('Editor Model - Model', () => {
|
||||
LINE3 + '\n' +
|
||||
LINE4 + '\r\n' +
|
||||
LINE5;
|
||||
thisModel = TextModel.createFromString(text);
|
||||
thisModel = createTextModel(text);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -349,7 +350,7 @@ suite('Editor Model - Model Line Separators', () => {
|
||||
LINE3 + '\u2028' +
|
||||
LINE4 + '\r\n' +
|
||||
LINE5;
|
||||
thisModel = TextModel.createFromString(text);
|
||||
thisModel = createTextModel(text);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -365,7 +366,7 @@ suite('Editor Model - Model Line Separators', () => {
|
||||
});
|
||||
|
||||
test('Bug 13333:Model should line break on lonely CR too', () => {
|
||||
let model = TextModel.createFromString('Hello\rWorld!\r\nAnother line');
|
||||
let model = createTextModel('Hello\rWorld!\r\nAnother line');
|
||||
assert.equal(model.getLineCount(), 3);
|
||||
assert.equal(model.getValue(), 'Hello\r\nWorld!\r\nAnother line');
|
||||
model.dispose();
|
||||
@@ -430,7 +431,7 @@ suite('Editor Model - Words', () => {
|
||||
|
||||
test('Get word at position', () => {
|
||||
const text = ['This text has some words. '];
|
||||
const thisModel = TextModel.createFromString(text.join('\n'));
|
||||
const thisModel = createTextModel(text.join('\n'));
|
||||
disposables.push(thisModel);
|
||||
|
||||
assert.deepEqual(thisModel.getWordAtPosition(new Position(1, 1)), { word: 'This', startColumn: 1, endColumn: 5 });
|
||||
@@ -451,7 +452,7 @@ suite('Editor Model - Words', () => {
|
||||
const innerMode = new InnerMode();
|
||||
disposables.push(outerMode, innerMode);
|
||||
|
||||
const model = TextModel.createFromString('ab<xx>ab<x>', undefined, outerMode.getLanguageIdentifier());
|
||||
const model = createTextModel('ab<xx>ab<x>', undefined, outerMode.getLanguageIdentifier());
|
||||
disposables.push(model);
|
||||
|
||||
assert.deepEqual(model.getWordAtPosition(new Position(1, 1)), { word: 'ab', startColumn: 1, endColumn: 3 });
|
||||
@@ -476,7 +477,7 @@ suite('Editor Model - Words', () => {
|
||||
};
|
||||
disposables.push(mode);
|
||||
|
||||
const thisModel = TextModel.createFromString('.🐷-a-b', undefined, MODE_ID);
|
||||
const thisModel = createTextModel('.🐷-a-b', undefined, MODE_ID);
|
||||
disposables.push(thisModel);
|
||||
|
||||
assert.deepEqual(thisModel.getWordAtPosition(new Position(1, 1)), { word: '.', startColumn: 1, endColumn: 2 });
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { EndOfLineSequence, IModelDeltaDecoration, TrackedRangeStickiness } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
// --------- utils
|
||||
|
||||
@@ -92,7 +93,7 @@ suite('Editor Model - Model Decorations', () => {
|
||||
LINE3 + '\n' +
|
||||
LINE4 + '\r\n' +
|
||||
LINE5;
|
||||
thisModel = TextModel.createFromString(text);
|
||||
thisModel = createTextModel(text);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -400,7 +401,7 @@ suite('Editor Model - Model Decorations', () => {
|
||||
});
|
||||
|
||||
test('removeAllDecorationsWithOwnerId can be called after model dispose', () => {
|
||||
let model = TextModel.createFromString('asd');
|
||||
let model = createTextModel('asd');
|
||||
model.dispose();
|
||||
model.removeAllDecorationsWithOwnerId(1);
|
||||
});
|
||||
@@ -415,7 +416,7 @@ suite('Editor Model - Model Decorations', () => {
|
||||
suite('Decorations and editing', () => {
|
||||
|
||||
function _runTest(decRange: Range, stickiness: TrackedRangeStickiness, editRange: Range, editText: string, editForceMoveMarkers: boolean, expectedDecRange: Range, msg: string): void {
|
||||
let model = TextModel.createFromString([
|
||||
let model = createTextModel([
|
||||
'My First Line',
|
||||
'My Second Line',
|
||||
'Third Line'
|
||||
@@ -1148,7 +1149,7 @@ suite('deltaDecorations', () => {
|
||||
|
||||
function testDeltaDecorations(text: string[], decorations: ILightWeightDecoration[], newDecorations: ILightWeightDecoration[]): void {
|
||||
|
||||
let model = TextModel.createFromString(text.join('\n'));
|
||||
let model = createTextModel(text.join('\n'));
|
||||
|
||||
// Add initial decorations & assert they are added
|
||||
let initialIds = model.deltaDecorations([], decorations.map(toModelDeltaDecoration));
|
||||
@@ -1177,7 +1178,7 @@ suite('deltaDecorations', () => {
|
||||
}
|
||||
|
||||
test('result respects input', () => {
|
||||
let model = TextModel.createFromString([
|
||||
let model = createTextModel([
|
||||
'Hello world,',
|
||||
'How are you?'
|
||||
].join('\n'));
|
||||
@@ -1265,7 +1266,7 @@ suite('deltaDecorations', () => {
|
||||
|
||||
test('issue #4317: editor.setDecorations doesn\'t update the hover message', () => {
|
||||
|
||||
let model = TextModel.createFromString('Hello world!');
|
||||
let model = createTextModel('Hello world!');
|
||||
|
||||
let ids = model.deltaDecorations([], [{
|
||||
range: {
|
||||
@@ -1299,7 +1300,7 @@ suite('deltaDecorations', () => {
|
||||
});
|
||||
|
||||
test('model doesn\'t get confused with individual tracked ranges', () => {
|
||||
let model = TextModel.createFromString([
|
||||
let model = createTextModel([
|
||||
'Hello world,',
|
||||
'How are you?'
|
||||
].join('\n'));
|
||||
@@ -1340,7 +1341,7 @@ suite('deltaDecorations', () => {
|
||||
});
|
||||
|
||||
test('issue #16922: Clicking on link doesn\'t seem to do anything', () => {
|
||||
let model = TextModel.createFromString([
|
||||
let model = createTextModel([
|
||||
'Hello world,',
|
||||
'How are you?',
|
||||
'Fine.',
|
||||
@@ -1371,7 +1372,7 @@ suite('deltaDecorations', () => {
|
||||
|
||||
test('issue #41492: URL highlighting persists after pasting over url', () => {
|
||||
|
||||
let model = TextModel.createFromString([
|
||||
let model = createTextModel([
|
||||
'My First Line'
|
||||
].join('\n'));
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import * as assert from 'assert';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
suite('Editor Model - Model Edit Operation', () => {
|
||||
const LINE1 = 'My First Line';
|
||||
@@ -23,7 +24,7 @@ suite('Editor Model - Model Edit Operation', () => {
|
||||
LINE3 + '\n' +
|
||||
LINE4 + '\r\n' +
|
||||
LINE5;
|
||||
model = TextModel.createFromString(text);
|
||||
model = createTextModel(text);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
|
||||
@@ -12,7 +12,7 @@ import { PieceTreeBase } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceT
|
||||
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 { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
import { SearchData } from 'vs/editor/common/model/textModelSearch';
|
||||
|
||||
const alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\r\n';
|
||||
@@ -1761,7 +1761,7 @@ function getValueInSnapshot(snapshot: ITextSnapshot) {
|
||||
}
|
||||
suite('snapshot', () => {
|
||||
test('bug #45564, piece tree pieces should be immutable', () => {
|
||||
const model = TextModel.createFromString('\n');
|
||||
const model = createTextModel('\n');
|
||||
model.applyEdits([
|
||||
{
|
||||
range: new Range(2, 1, 2, 1),
|
||||
@@ -1789,7 +1789,7 @@ suite('snapshot', () => {
|
||||
});
|
||||
|
||||
test('immutable snapshot 1', () => {
|
||||
const model = TextModel.createFromString('abc\ndef');
|
||||
const model = createTextModel('abc\ndef');
|
||||
const snapshot = model.createSnapshot();
|
||||
model.applyEdits([
|
||||
{
|
||||
@@ -1809,7 +1809,7 @@ suite('snapshot', () => {
|
||||
});
|
||||
|
||||
test('immutable snapshot 2', () => {
|
||||
const model = TextModel.createFromString('abc\ndef');
|
||||
const model = createTextModel('abc\ndef');
|
||||
const snapshot = model.createSnapshot();
|
||||
model.applyEdits([
|
||||
{
|
||||
@@ -1829,7 +1829,7 @@ suite('snapshot', () => {
|
||||
});
|
||||
|
||||
test('immutable snapshot 3', () => {
|
||||
const model = TextModel.createFromString('abc\ndef');
|
||||
const model = createTextModel('abc\ndef');
|
||||
model.applyEdits([
|
||||
{
|
||||
range: new Range(2, 4, 2, 4),
|
||||
@@ -1896,4 +1896,4 @@ suite('chunk based search', () => {
|
||||
assert.equal(ret.length, 1);
|
||||
assert.deepEqual(ret[0].range, new Range(2, 2, 2, 3));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -163,7 +163,7 @@ suite('Editor Model - TextModel', () => {
|
||||
|
||||
test('getValueLengthInRange', () => {
|
||||
|
||||
let m = TextModel.createFromString('My First Line\r\nMy Second Line\r\nMy Third Line');
|
||||
let m = createTextModel('My First Line\r\nMy Second Line\r\nMy Third Line');
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 1, 1)), ''.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 1, 2)), 'M'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 1, 3)), 'y'.length);
|
||||
@@ -176,7 +176,7 @@ suite('Editor Model - TextModel', () => {
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 3, 1000)), 'y First Line\r\nMy Second Line\r\nMy Third Line'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 1000, 1000)), 'My First Line\r\nMy Second Line\r\nMy Third Line'.length);
|
||||
|
||||
m = TextModel.createFromString('My First Line\nMy Second Line\nMy Third Line');
|
||||
m = createTextModel('My First Line\nMy Second Line\nMy Third Line');
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 1, 1)), ''.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 1, 1, 2)), 'M'.length);
|
||||
assert.equal(m.getValueLengthInRange(new Range(1, 2, 1, 3)), 'y'.length);
|
||||
@@ -662,7 +662,7 @@ suite('Editor Model - TextModel', () => {
|
||||
|
||||
test('validatePosition', () => {
|
||||
|
||||
let m = TextModel.createFromString('line one\nline two');
|
||||
let m = createTextModel('line one\nline two');
|
||||
|
||||
assert.deepEqual(m.validatePosition(new Position(0, 0)), new Position(1, 1));
|
||||
assert.deepEqual(m.validatePosition(new Position(0, 1)), new Position(1, 1));
|
||||
@@ -691,7 +691,7 @@ suite('Editor Model - TextModel', () => {
|
||||
|
||||
test('validatePosition around high-low surrogate pairs 1', () => {
|
||||
|
||||
let m = TextModel.createFromString('a📚b');
|
||||
let m = createTextModel('a📚b');
|
||||
|
||||
assert.deepEqual(m.validatePosition(new Position(0, 0)), new Position(1, 1));
|
||||
assert.deepEqual(m.validatePosition(new Position(0, 1)), new Position(1, 1));
|
||||
@@ -718,7 +718,7 @@ suite('Editor Model - TextModel', () => {
|
||||
|
||||
test('validatePosition around high-low surrogate pairs 2', () => {
|
||||
|
||||
let m = TextModel.createFromString('a📚📚b');
|
||||
let m = createTextModel('a📚📚b');
|
||||
|
||||
assert.deepEqual(m.validatePosition(new Position(1, 1)), new Position(1, 1));
|
||||
assert.deepEqual(m.validatePosition(new Position(1, 2)), new Position(1, 2));
|
||||
@@ -732,7 +732,7 @@ suite('Editor Model - TextModel', () => {
|
||||
|
||||
test('validatePosition handle NaN.', () => {
|
||||
|
||||
let m = TextModel.createFromString('line one\nline two');
|
||||
let m = createTextModel('line one\nline two');
|
||||
|
||||
assert.deepEqual(m.validatePosition(new Position(NaN, 1)), new Position(1, 1));
|
||||
assert.deepEqual(m.validatePosition(new Position(1, NaN)), new Position(1, 1));
|
||||
@@ -743,7 +743,7 @@ suite('Editor Model - TextModel', () => {
|
||||
});
|
||||
|
||||
test('issue #71480: validatePosition handle floats', () => {
|
||||
let m = TextModel.createFromString('line one\nline two');
|
||||
let m = createTextModel('line one\nline two');
|
||||
|
||||
assert.deepEqual(m.validatePosition(new Position(0.2, 1)), new Position(1, 1), 'a');
|
||||
assert.deepEqual(m.validatePosition(new Position(1.2, 1)), new Position(1, 1), 'b');
|
||||
@@ -756,7 +756,7 @@ suite('Editor Model - TextModel', () => {
|
||||
});
|
||||
|
||||
test('issue #71480: validateRange handle floats', () => {
|
||||
let m = TextModel.createFromString('line one\nline two');
|
||||
let m = createTextModel('line one\nline two');
|
||||
|
||||
assert.deepEqual(m.validateRange(new Range(0.2, 1.5, 0.8, 2.5)), new Range(1, 1, 1, 1));
|
||||
assert.deepEqual(m.validateRange(new Range(1.2, 1.7, 1.8, 2.2)), new Range(1, 1, 1, 2));
|
||||
@@ -764,7 +764,7 @@ suite('Editor Model - TextModel', () => {
|
||||
|
||||
test('validateRange around high-low surrogate pairs 1', () => {
|
||||
|
||||
let m = TextModel.createFromString('a📚b');
|
||||
let m = createTextModel('a📚b');
|
||||
|
||||
assert.deepEqual(m.validateRange(new Range(0, 0, 0, 1)), new Range(1, 1, 1, 1));
|
||||
assert.deepEqual(m.validateRange(new Range(0, 0, 0, 7)), new Range(1, 1, 1, 1));
|
||||
@@ -792,7 +792,7 @@ suite('Editor Model - TextModel', () => {
|
||||
|
||||
test('validateRange around high-low surrogate pairs 2', () => {
|
||||
|
||||
let m = TextModel.createFromString('a📚📚b');
|
||||
let m = createTextModel('a📚📚b');
|
||||
|
||||
assert.deepEqual(m.validateRange(new Range(0, 0, 0, 1)), new Range(1, 1, 1, 1));
|
||||
assert.deepEqual(m.validateRange(new Range(0, 0, 0, 7)), new Range(1, 1, 1, 1));
|
||||
@@ -835,7 +835,7 @@ suite('Editor Model - TextModel', () => {
|
||||
|
||||
test('modifyPosition', () => {
|
||||
|
||||
let m = TextModel.createFromString('line one\nline two');
|
||||
let m = createTextModel('line one\nline two');
|
||||
assert.deepEqual(m.modifyPosition(new Position(1, 1), 0), new Position(1, 1));
|
||||
assert.deepEqual(m.modifyPosition(new Position(0, 0), 0), new Position(1, 1));
|
||||
assert.deepEqual(m.modifyPosition(new Position(30, 1), 0), new Position(2, 9));
|
||||
@@ -913,7 +913,7 @@ suite('Editor Model - TextModel', () => {
|
||||
});
|
||||
|
||||
test('getLineFirstNonWhitespaceColumn', () => {
|
||||
let model = TextModel.createFromString([
|
||||
let model = createTextModel([
|
||||
'asd',
|
||||
' asd',
|
||||
'\tasd',
|
||||
@@ -943,7 +943,7 @@ suite('Editor Model - TextModel', () => {
|
||||
});
|
||||
|
||||
test('getLineLastNonWhitespaceColumn', () => {
|
||||
let model = TextModel.createFromString([
|
||||
let model = createTextModel([
|
||||
'asd',
|
||||
'asd ',
|
||||
'asd\t',
|
||||
@@ -973,7 +973,7 @@ suite('Editor Model - TextModel', () => {
|
||||
});
|
||||
|
||||
test('#50471. getValueInRange with invalid range', () => {
|
||||
let m = TextModel.createFromString('My First Line\r\nMy Second Line\r\nMy Third Line');
|
||||
let m = createTextModel('My First Line\r\nMy Second Line\r\nMy Third Line');
|
||||
assert.equal(m.getValueInRange(new Range(1, NaN, 1, 3)), 'My');
|
||||
assert.equal(m.getValueInRange(new Range(NaN, NaN, NaN, NaN)), '');
|
||||
});
|
||||
@@ -982,24 +982,24 @@ suite('Editor Model - TextModel', () => {
|
||||
suite('TextModel.mightContainRTL', () => {
|
||||
|
||||
test('nope', () => {
|
||||
let model = TextModel.createFromString('hello world!');
|
||||
let model = createTextModel('hello world!');
|
||||
assert.equal(model.mightContainRTL(), false);
|
||||
});
|
||||
|
||||
test('yes', () => {
|
||||
let model = TextModel.createFromString('Hello,\nזוהי עובדה מבוססת שדעתו');
|
||||
let model = createTextModel('Hello,\nזוהי עובדה מבוססת שדעתו');
|
||||
assert.equal(model.mightContainRTL(), true);
|
||||
});
|
||||
|
||||
test('setValue resets 1', () => {
|
||||
let model = TextModel.createFromString('hello world!');
|
||||
let model = createTextModel('hello world!');
|
||||
assert.equal(model.mightContainRTL(), false);
|
||||
model.setValue('Hello,\nזוהי עובדה מבוססת שדעתו');
|
||||
assert.equal(model.mightContainRTL(), true);
|
||||
});
|
||||
|
||||
test('setValue resets 2', () => {
|
||||
let model = TextModel.createFromString('Hello,\nهناك حقيقة مثبتة منذ زمن طويل');
|
||||
let model = createTextModel('Hello,\nهناك حقيقة مثبتة منذ زمن طويل');
|
||||
assert.equal(model.mightContainRTL(), true);
|
||||
model.setValue('hello world!');
|
||||
assert.equal(model.mightContainRTL(), false);
|
||||
@@ -1010,14 +1010,14 @@ suite('TextModel.mightContainRTL', () => {
|
||||
suite('TextModel.createSnapshot', () => {
|
||||
|
||||
test('empty file', () => {
|
||||
let model = TextModel.createFromString('');
|
||||
let model = createTextModel('');
|
||||
let snapshot = model.createSnapshot();
|
||||
assert.equal(snapshot.read(), null);
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('file with BOM', () => {
|
||||
let model = TextModel.createFromString(UTF8_BOM_CHARACTER + 'Hello');
|
||||
let model = createTextModel(UTF8_BOM_CHARACTER + 'Hello');
|
||||
assert.equal(model.getLineContent(1), 'Hello');
|
||||
let snapshot = model.createSnapshot(true);
|
||||
assert.equal(snapshot.read(), UTF8_BOM_CHARACTER + 'Hello');
|
||||
@@ -1026,7 +1026,7 @@ suite('TextModel.createSnapshot', () => {
|
||||
});
|
||||
|
||||
test('regular file', () => {
|
||||
let model = TextModel.createFromString('My First Line\n\t\tMy Second Line\n Third Line\n\n1');
|
||||
let model = createTextModel('My First Line\n\t\tMy Second Line\n Third Line\n\n1');
|
||||
let snapshot = model.createSnapshot();
|
||||
assert.equal(snapshot.read(), 'My First Line\n\t\tMy Second Line\n Third Line\n\n1');
|
||||
assert.equal(snapshot.read(), null);
|
||||
@@ -1040,7 +1040,7 @@ suite('TextModel.createSnapshot', () => {
|
||||
}
|
||||
const text = lines.join('\n');
|
||||
|
||||
let model = TextModel.createFromString(text);
|
||||
let model = createTextModel(text);
|
||||
let snapshot = model.createSnapshot();
|
||||
let actual = '';
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ 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';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
// --------- Find
|
||||
suite('TextModelSearch', () => {
|
||||
@@ -51,12 +52,12 @@ suite('TextModelSearch', () => {
|
||||
let expectedMatches = expectedRanges.map(entry => new FindMatch(entry, null));
|
||||
let searchParams = new SearchParams(searchString, isRegex, matchCase, wordSeparators);
|
||||
|
||||
let model = TextModel.createFromString(text);
|
||||
let model = createTextModel(text);
|
||||
_assertFindMatches(model, searchParams, expectedMatches);
|
||||
model.dispose();
|
||||
|
||||
|
||||
let model2 = TextModel.createFromString(text);
|
||||
let model2 = createTextModel(text);
|
||||
model2.setEOL(EndOfLineSequence.CRLF);
|
||||
_assertFindMatches(model2, searchParams, expectedMatches);
|
||||
model2.dispose();
|
||||
@@ -380,7 +381,7 @@ suite('TextModelSearch', () => {
|
||||
});
|
||||
|
||||
test('findNextMatch without regex', () => {
|
||||
let model = TextModel.createFromString('line line one\nline two\nthree');
|
||||
let model = createTextModel('line line one\nline two\nthree');
|
||||
|
||||
let searchParams = new SearchParams('line', false, false, null);
|
||||
|
||||
@@ -403,7 +404,7 @@ suite('TextModelSearch', () => {
|
||||
});
|
||||
|
||||
test('findNextMatch with beginning boundary regex', () => {
|
||||
let model = TextModel.createFromString('line one\nline two\nthree');
|
||||
let model = createTextModel('line one\nline two\nthree');
|
||||
|
||||
let searchParams = new SearchParams('^line', true, false, null);
|
||||
|
||||
@@ -423,7 +424,7 @@ suite('TextModelSearch', () => {
|
||||
});
|
||||
|
||||
test('findNextMatch with beginning boundary regex and line has repetitive beginnings', () => {
|
||||
let model = TextModel.createFromString('line line one\nline two\nthree');
|
||||
let model = createTextModel('line line one\nline two\nthree');
|
||||
|
||||
let searchParams = new SearchParams('^line', true, false, null);
|
||||
|
||||
@@ -443,7 +444,7 @@ suite('TextModelSearch', () => {
|
||||
});
|
||||
|
||||
test('findNextMatch with beginning boundary multiline regex and line has repetitive beginnings', () => {
|
||||
let model = TextModel.createFromString('line line one\nline two\nline three\nline four');
|
||||
let model = createTextModel('line line one\nline two\nline three\nline four');
|
||||
|
||||
let searchParams = new SearchParams('^line.*\\nline', true, false, null);
|
||||
|
||||
@@ -460,7 +461,7 @@ suite('TextModelSearch', () => {
|
||||
});
|
||||
|
||||
test('findNextMatch with ending boundary regex', () => {
|
||||
let model = TextModel.createFromString('one line line\ntwo line\nthree');
|
||||
let model = createTextModel('one line line\ntwo line\nthree');
|
||||
|
||||
let searchParams = new SearchParams('line$', true, false, null);
|
||||
|
||||
@@ -480,7 +481,7 @@ suite('TextModelSearch', () => {
|
||||
});
|
||||
|
||||
test('findMatches with capturing matches', () => {
|
||||
let model = TextModel.createFromString('one line line\ntwo line\nthree');
|
||||
let model = createTextModel('one line line\ntwo line\nthree');
|
||||
|
||||
let searchParams = new SearchParams('(l(in)e)', true, false, null);
|
||||
|
||||
@@ -495,7 +496,7 @@ suite('TextModelSearch', () => {
|
||||
});
|
||||
|
||||
test('findMatches multiline with capturing matches', () => {
|
||||
let model = TextModel.createFromString('one line line\ntwo line\nthree');
|
||||
let model = createTextModel('one line line\ntwo line\nthree');
|
||||
|
||||
let searchParams = new SearchParams('(l(in)e)\\n', true, false, null);
|
||||
|
||||
@@ -509,7 +510,7 @@ suite('TextModelSearch', () => {
|
||||
});
|
||||
|
||||
test('findNextMatch with capturing matches', () => {
|
||||
let model = TextModel.createFromString('one line line\ntwo line\nthree');
|
||||
let model = createTextModel('one line line\ntwo line\nthree');
|
||||
|
||||
let searchParams = new SearchParams('(l(in)e)', true, false, null);
|
||||
|
||||
@@ -520,7 +521,7 @@ suite('TextModelSearch', () => {
|
||||
});
|
||||
|
||||
test('findNextMatch multiline with capturing matches', () => {
|
||||
let model = TextModel.createFromString('one line line\ntwo line\nthree');
|
||||
let model = createTextModel('one line line\ntwo line\nthree');
|
||||
|
||||
let searchParams = new SearchParams('(l(in)e)\\n', true, false, null);
|
||||
|
||||
@@ -531,7 +532,7 @@ suite('TextModelSearch', () => {
|
||||
});
|
||||
|
||||
test('findPreviousMatch with capturing matches', () => {
|
||||
let model = TextModel.createFromString('one line line\ntwo line\nthree');
|
||||
let model = createTextModel('one line line\ntwo line\nthree');
|
||||
|
||||
let searchParams = new SearchParams('(l(in)e)', true, false, null);
|
||||
|
||||
@@ -542,7 +543,7 @@ suite('TextModelSearch', () => {
|
||||
});
|
||||
|
||||
test('findPreviousMatch multiline with capturing matches', () => {
|
||||
let model = TextModel.createFromString('one line line\ntwo line\nthree');
|
||||
let model = createTextModel('one line line\ntwo line\nthree');
|
||||
|
||||
let searchParams = new SearchParams('(l(in)e)\\n', true, false, null);
|
||||
|
||||
@@ -553,7 +554,7 @@ suite('TextModelSearch', () => {
|
||||
});
|
||||
|
||||
test('\\n matches \\r\\n', () => {
|
||||
let model = TextModel.createFromString('a\r\nb\r\nc\r\nd\r\ne\r\nf\r\ng\r\nh\r\ni');
|
||||
let model = createTextModel('a\r\nb\r\nc\r\nd\r\ne\r\nf\r\ng\r\nh\r\ni');
|
||||
|
||||
assert.equal(model.getEOL(), '\r\n');
|
||||
|
||||
@@ -576,7 +577,7 @@ suite('TextModelSearch', () => {
|
||||
});
|
||||
|
||||
test('\\r can never be found', () => {
|
||||
let model = TextModel.createFromString('a\r\nb\r\nc\r\nd\r\ne\r\nf\r\ng\r\nh\r\ni');
|
||||
let model = createTextModel('a\r\nb\r\nc\r\nd\r\ne\r\nf\r\ng\r\nh\r\ni');
|
||||
|
||||
assert.equal(model.getEOL(), '\r\n');
|
||||
|
||||
@@ -763,7 +764,7 @@ suite('TextModelSearch', () => {
|
||||
});
|
||||
|
||||
test('issue #74715. \\d* finds empty string and stops searching.', () => {
|
||||
let model = TextModel.createFromString('10.243.30.10');
|
||||
let model = createTextModel('10.243.30.10');
|
||||
|
||||
let searchParams = new SearchParams('\\d*', true, false, null);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ 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 { ViewLineToken } from 'vs/editor/test/common/core/viewLineToken';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
suite('TextModelWithTokens', () => {
|
||||
|
||||
@@ -72,7 +73,7 @@ suite('TextModelWithTokens', () => {
|
||||
brackets: brackets
|
||||
});
|
||||
|
||||
let model = TextModel.createFromString(
|
||||
let model = createTextModel(
|
||||
contents.join('\n'),
|
||||
TextModel.DEFAULT_CREATION_OPTIONS,
|
||||
languageIdentifier
|
||||
@@ -178,7 +179,7 @@ suite('TextModelWithTokens - bracket matching', () => {
|
||||
let text =
|
||||
')]}{[(' + '\n' +
|
||||
')]}{[(';
|
||||
let model = TextModel.createFromString(text, undefined, languageIdentifier);
|
||||
let model = createTextModel(text, undefined, languageIdentifier);
|
||||
|
||||
assertIsNotBracket(model, 1, 1);
|
||||
assertIsNotBracket(model, 1, 2);
|
||||
@@ -206,7 +207,7 @@ suite('TextModelWithTokens - bracket matching', () => {
|
||||
'}, bar: {hallo: [{' + '\n' +
|
||||
'}, {' + '\n' +
|
||||
'}]}}';
|
||||
let model = TextModel.createFromString(text, undefined, languageIdentifier);
|
||||
let model = createTextModel(text, undefined, languageIdentifier);
|
||||
|
||||
let brackets: [Position, Range, Range][] = [
|
||||
[new Position(1, 11), new Range(1, 11, 1, 12), new Range(5, 4, 5, 5)],
|
||||
@@ -284,7 +285,7 @@ suite('TextModelWithTokens', () => {
|
||||
'end;',
|
||||
].join('\n');
|
||||
|
||||
const model = TextModel.createFromString(text, undefined, languageIdentifier);
|
||||
const model = createTextModel(text, undefined, languageIdentifier);
|
||||
|
||||
// <if> ... <end ifa> is not matched
|
||||
assertIsNotBracket(model, 10, 9);
|
||||
@@ -322,7 +323,7 @@ suite('TextModelWithTokens', () => {
|
||||
'endrecord',
|
||||
].join('\n');
|
||||
|
||||
const model = TextModel.createFromString(text, undefined, languageIdentifier);
|
||||
const model = createTextModel(text, undefined, languageIdentifier);
|
||||
|
||||
// <recordbegin> ... <endrecord> is matched
|
||||
assertIsBracket(model, new Position(1, 1), [new Range(1, 1, 1, 12), new Range(4, 1, 4, 10)]);
|
||||
@@ -388,7 +389,7 @@ suite('TextModelWithTokens', () => {
|
||||
],
|
||||
});
|
||||
|
||||
const model = TextModel.createFromString([
|
||||
const model = createTextModel([
|
||||
'function hello() {',
|
||||
' console.log(`${100}`);',
|
||||
'}'
|
||||
@@ -459,7 +460,7 @@ suite('TextModelWithTokens regression tests', () => {
|
||||
let registration1 = TokenizationRegistry.register(LANG_ID1, tokenizationSupport);
|
||||
let registration2 = TokenizationRegistry.register(LANG_ID2, tokenizationSupport);
|
||||
|
||||
let model = TextModel.createFromString('A model with\ntwo lines');
|
||||
let model = createTextModel('A model with\ntwo lines');
|
||||
|
||||
assertViewLineTokens(model, 1, true, [createViewLineToken(12, 1)]);
|
||||
assertViewLineTokens(model, 2, true, [createViewLineToken(9, 1)]);
|
||||
@@ -498,7 +499,7 @@ suite('TextModelWithTokens regression tests', () => {
|
||||
]
|
||||
});
|
||||
|
||||
let model = TextModel.createFromString([
|
||||
let model = createTextModel([
|
||||
'Imports System',
|
||||
'Imports System.Collections.Generic',
|
||||
'',
|
||||
@@ -528,7 +529,7 @@ suite('TextModelWithTokens regression tests', () => {
|
||||
]
|
||||
});
|
||||
|
||||
let model = TextModel.createFromString([
|
||||
let model = createTextModel([
|
||||
'sequence "outer"',
|
||||
' sequence "inner"',
|
||||
' endsequence',
|
||||
@@ -561,7 +562,7 @@ suite('TextModelWithTokens regression tests', () => {
|
||||
|
||||
let registration = TokenizationRegistry.register(outerMode.language, tokenizationSupport);
|
||||
|
||||
let model = TextModel.createFromString('A model with one line', undefined, outerMode);
|
||||
let model = createTextModel('A model with one line', undefined, outerMode);
|
||||
|
||||
model.forceTokenization(1);
|
||||
assert.equal(model.getLanguageIdAtPosition(1, 1), innerMode.id);
|
||||
@@ -574,7 +575,7 @@ suite('TextModelWithTokens regression tests', () => {
|
||||
suite('TextModel.getLineIndentGuide', () => {
|
||||
function assertIndentGuides(lines: [number, number, number, number, string][], tabSize: number): void {
|
||||
let text = lines.map(l => l[4]).join('\n');
|
||||
let model = TextModel.createFromString(text);
|
||||
let model = createTextModel(text);
|
||||
model.updateOptions({ tabSize: tabSize });
|
||||
|
||||
let actualIndents = model.getLinesIndentGuides(1, model.getLineCount());
|
||||
@@ -747,7 +748,7 @@ suite('TextModel.getLineIndentGuide', () => {
|
||||
});
|
||||
|
||||
test('issue #49173', () => {
|
||||
let model = TextModel.createFromString([
|
||||
let model = createTextModel([
|
||||
'class A {',
|
||||
' public m1(): void {',
|
||||
' }',
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Range } from 'vs/editor/common/core/range';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
|
||||
import { MetadataConsts, TokenMetadata } from 'vs/editor/common/modes';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
suite('TokensStore', () => {
|
||||
|
||||
@@ -96,7 +97,7 @@ suite('TokensStore', () => {
|
||||
|
||||
function testTokensAdjustment(rawInitialState: string[], edits: IIdentifiedSingleEditOperation[], rawFinalState: string[]) {
|
||||
const initialState = parseTokensState(rawInitialState);
|
||||
const model = TextModel.createFromString(initialState.text);
|
||||
const model = createTextModel(initialState.text);
|
||||
model.setSemanticTokens([initialState.tokens]);
|
||||
|
||||
model.applyEdits(edits);
|
||||
|
||||
@@ -11,7 +11,7 @@ import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { createStringBuilder } from 'vs/editor/common/core/stringBuilder';
|
||||
import { DefaultEndOfLine } from 'vs/editor/common/model';
|
||||
import { TextModel, createTextBuffer } from 'vs/editor/common/model/textModel';
|
||||
import { createTextBuffer } from 'vs/editor/common/model/textModel';
|
||||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -19,6 +19,9 @@ import { TestConfigurationService } from 'vs/platform/configuration/test/common/
|
||||
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
|
||||
import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService';
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
const GENERATE_TESTS = false;
|
||||
|
||||
@@ -30,7 +33,7 @@ suite('ModelService', () => {
|
||||
configService.setUserConfiguration('files', { 'eol': '\n' });
|
||||
configService.setUserConfiguration('files', { 'eol': '\r\n' }, URI.file(platform.isWindows ? 'c:\\myroot' : '/myroot'));
|
||||
|
||||
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService), new TestThemeService(), new NullLogService(), new UndoRedoService());
|
||||
modelService = new ModelServiceImpl(configService, new TestTextResourcePropertiesService(configService), new TestThemeService(), new NullLogService(), new UndoRedoService(new TestDialogService(), new TestNotificationService()));
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
@@ -49,7 +52,7 @@ suite('ModelService', () => {
|
||||
|
||||
test('_computeEdits no change', function () {
|
||||
|
||||
const model = TextModel.createFromString(
|
||||
const model = createTextModel(
|
||||
[
|
||||
'This is line one', //16
|
||||
'and this is line number two', //27
|
||||
@@ -75,7 +78,7 @@ suite('ModelService', () => {
|
||||
|
||||
test('_computeEdits first line changed', function () {
|
||||
|
||||
const model = TextModel.createFromString(
|
||||
const model = createTextModel(
|
||||
[
|
||||
'This is line one', //16
|
||||
'and this is line number two', //27
|
||||
@@ -103,7 +106,7 @@ suite('ModelService', () => {
|
||||
|
||||
test('_computeEdits EOL changed', function () {
|
||||
|
||||
const model = TextModel.createFromString(
|
||||
const model = createTextModel(
|
||||
[
|
||||
'This is line one', //16
|
||||
'and this is line number two', //27
|
||||
@@ -129,7 +132,7 @@ suite('ModelService', () => {
|
||||
|
||||
test('_computeEdits EOL and other change 1', function () {
|
||||
|
||||
const model = TextModel.createFromString(
|
||||
const model = createTextModel(
|
||||
[
|
||||
'This is line one', //16
|
||||
'and this is line number two', //27
|
||||
@@ -165,7 +168,7 @@ suite('ModelService', () => {
|
||||
|
||||
test('_computeEdits EOL and other change 2', function () {
|
||||
|
||||
const model = TextModel.createFromString(
|
||||
const model = createTextModel(
|
||||
[
|
||||
'package main', // 1
|
||||
'func foo() {', // 2
|
||||
@@ -307,7 +310,7 @@ suite('ModelService', () => {
|
||||
});
|
||||
|
||||
function assertComputeEdits(lines1: string[], lines2: string[]): void {
|
||||
const model = TextModel.createFromString(lines1.join('\n'));
|
||||
const model = createTextModel(lines1.join('\n'));
|
||||
const textBuffer = createTextBuffer(lines2.join('\n'), DefaultEndOfLine.LF);
|
||||
|
||||
// compute required edits
|
||||
|
||||
@@ -18,6 +18,7 @@ import { LineBreakData, ISimpleModel, SplitLine, SplitLinesCollection } from 'vs
|
||||
import { ViewLineData } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
suite('Editor ViewModel - SplitLinesCollection', () => {
|
||||
test('SplitLine', () => {
|
||||
@@ -96,7 +97,7 @@ suite('Editor ViewModel - SplitLinesCollection', () => {
|
||||
|
||||
const lineBreaksComputerFactory = new MonospaceLineBreaksComputerFactory(wordWrapBreakBeforeCharacters, wordWrapBreakAfterCharacters);
|
||||
|
||||
const model = TextModel.createFromString([
|
||||
const model = createTextModel([
|
||||
'int main() {',
|
||||
'\tprintf("Hello world!");',
|
||||
'}',
|
||||
@@ -347,7 +348,7 @@ suite('SplitLinesCollection', () => {
|
||||
};
|
||||
const LANGUAGE_ID = 'modelModeTest1';
|
||||
languageRegistration = modes.TokenizationRegistry.register(LANGUAGE_ID, tokenizationSupport);
|
||||
model = TextModel.createFromString(_text.join('\n'), undefined, new modes.LanguageIdentifier(LANGUAGE_ID, 0));
|
||||
model = createTextModel(_text.join('\n'), undefined, new modes.LanguageIdentifier(LANGUAGE_ID, 0));
|
||||
// force tokenization
|
||||
model.forceTokenization(model.getLineCount());
|
||||
});
|
||||
|
||||
@@ -8,12 +8,13 @@ import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl';
|
||||
import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration';
|
||||
import { MonospaceLineBreaksComputerFactory } from 'vs/editor/common/viewModel/monospaceLineBreaksComputer';
|
||||
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
export function testViewModel(text: string[], options: IEditorOptions, callback: (viewModel: ViewModel, model: TextModel) => void): void {
|
||||
const EDITOR_ID = 1;
|
||||
|
||||
const configuration = new TestConfiguration(options);
|
||||
const model = TextModel.createFromString(text.join('\n'));
|
||||
const model = createTextModel(text.join('\n'));
|
||||
const monospaceLineBreaksComputerFactory = MonospaceLineBreaksComputerFactory.create(configuration.options);
|
||||
const viewModel = new ViewModel(EDITOR_ID, configuration, model, monospaceLineBreaksComputerFactory, monospaceLineBreaksComputerFactory, null!);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user