mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge VS Code 1.21 source code (#1067)
* Initial VS Code 1.21 file copy with patches * A few more merges * Post npm install * Fix batch of build breaks * Fix more build breaks * Fix more build errors * Fix more build breaks * Runtime fixes 1 * Get connection dialog working with some todos * Fix a few packaging issues * Copy several node_modules to package build to fix loader issues * Fix breaks from master * A few more fixes * Make tests pass * First pass of license header updates * Second pass of license header updates * Fix restore dialog issues * Remove add additional themes menu items * fix select box issues where the list doesn't show up * formatting * Fix editor dispose issue * Copy over node modules to correct location on all platforms
This commit is contained in:
@@ -8,7 +8,7 @@ import * as assert from 'assert';
|
||||
import { ShiftCommand } from 'vs/editor/common/commands/shiftCommand';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/editorCommon';
|
||||
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
|
||||
import { IndentAction } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import { getEditOperation, testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
@@ -21,10 +21,8 @@ import { LanguageIdentifier } from 'vs/editor/common/modes';
|
||||
*/
|
||||
export function createSingleEditOp(text: string, positionLineNumber: number, positionColumn: number, selectionLineNumber: number = positionLineNumber, selectionColumn: number = positionColumn): IIdentifiedSingleEditOperation {
|
||||
return {
|
||||
identifier: null,
|
||||
range: new Range(selectionLineNumber, selectionColumn, positionLineNumber, positionColumn),
|
||||
text: text,
|
||||
forceMoveMarkers: false
|
||||
text: text
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ 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 { Selection } from 'vs/editor/common/core/selection';
|
||||
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/editorCommon';
|
||||
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
|
||||
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { Model } from 'vs/editor/common/model/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration';
|
||||
import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl';
|
||||
import { Cursor } from 'vs/editor/common/controller/cursor';
|
||||
@@ -199,13 +199,17 @@ suite('SideEditing', () => {
|
||||
];
|
||||
|
||||
function _runTest(selection: Selection, editRange: Range, editText: string, editForceMoveMarkers: boolean, expected: Selection, msg: string): void {
|
||||
const model = Model.createFromString(LINES.join('\n'));
|
||||
const model = TextModel.createFromString(LINES.join('\n'));
|
||||
const config = new TestConfiguration(null);
|
||||
const viewModel = new ViewModel(0, config, model, null);
|
||||
const cursor = new Cursor(config, model, viewModel);
|
||||
|
||||
cursor.setSelections('tests', [selection]);
|
||||
model.applyEdits([{ range: editRange, text: editText, forceMoveMarkers: editForceMoveMarkers, identifier: null }]);
|
||||
model.applyEdits([{
|
||||
range: editRange,
|
||||
text: editText,
|
||||
forceMoveMarkers: editForceMoveMarkers
|
||||
}]);
|
||||
const actual = cursor.getSelection();
|
||||
assert.deepEqual(actual.toString(), expected.toString(), msg);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { TrimTrailingWhitespaceCommand, trimTrailingWhitespace } from 'vs/editor
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/editorCommon';
|
||||
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
|
||||
import { getEditOperation } from 'vs/editor/test/browser/testCommand';
|
||||
import { withEditorModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
|
||||
@@ -18,10 +18,8 @@ import { withEditorModel } from 'vs/editor/test/common/editorTestUtils';
|
||||
*/
|
||||
function createInsertDeleteSingleEditOp(text: string, positionLineNumber: number, positionColumn: number, selectionLineNumber: number = positionLineNumber, selectionColumn: number = positionColumn): IIdentifiedSingleEditOperation {
|
||||
return {
|
||||
identifier: null,
|
||||
range: new Range(selectionLineNumber, selectionColumn, positionLineNumber, positionColumn),
|
||||
text: text,
|
||||
forceMoveMarkers: true
|
||||
text: text
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,10 +28,8 @@ function createInsertDeleteSingleEditOp(text: string, positionLineNumber: number
|
||||
*/
|
||||
export function createSingleEditOp(text: string, positionLineNumber: number, positionColumn: number, selectionLineNumber: number = positionLineNumber, selectionColumn: number = positionColumn): IIdentifiedSingleEditOperation {
|
||||
return {
|
||||
identifier: null,
|
||||
range: new Range(selectionLineNumber, selectionColumn, positionLineNumber, positionColumn),
|
||||
text: text,
|
||||
forceMoveMarkers: false
|
||||
text: text
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,9 @@ 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 { Selection } from 'vs/editor/common/core/selection';
|
||||
import {
|
||||
EndOfLinePreference, Handler,
|
||||
DefaultEndOfLine, ITextModelCreationOptions, ICommand,
|
||||
ITokenizedModel, IEditOperationBuilder, ICursorStateComputerData, EndOfLineSequence
|
||||
} from 'vs/editor/common/editorCommon';
|
||||
import { Model } from 'vs/editor/common/model/model';
|
||||
import { Handler, ICommand, IEditOperationBuilder, ICursorStateComputerData } from 'vs/editor/common/editorCommon';
|
||||
import { EndOfLinePreference, DefaultEndOfLine, ITextModelCreationOptions, ITextModel, EndOfLineSequence } from 'vs/editor/common/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { IndentAction, IndentationRule } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration';
|
||||
@@ -24,7 +21,6 @@ import { LanguageIdentifier } from 'vs/editor/common/modes';
|
||||
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { CoreNavigationCommands, CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands';
|
||||
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl';
|
||||
let H = Handler;
|
||||
|
||||
@@ -34,7 +30,7 @@ function cursorCommand(cursor: Cursor, command: string, extraData?: any, overwri
|
||||
cursor.trigger(overwriteSource || 'tests', command, extraData);
|
||||
}
|
||||
|
||||
function cursorCommandAndTokenize(model: Model, cursor: Cursor, command: string, extraData?: any, overwriteSource?: string) {
|
||||
function cursorCommandAndTokenize(model: TextModel, cursor: Cursor, command: string, extraData?: any, overwriteSource?: string) {
|
||||
cursor.trigger(overwriteSource || 'tests', command, extraData);
|
||||
model.forceTokenization(model.getLineCount());
|
||||
}
|
||||
@@ -137,7 +133,7 @@ suite('Editor Controller - Cursor', () => {
|
||||
const LINE4 = '';
|
||||
const LINE5 = '1';
|
||||
|
||||
let thisModel: Model;
|
||||
let thisModel: TextModel;
|
||||
let thisConfiguration: TestConfiguration;
|
||||
let thisViewModel: ViewModel;
|
||||
let thisCursor: Cursor;
|
||||
@@ -150,7 +146,7 @@ suite('Editor Controller - Cursor', () => {
|
||||
LINE4 + '\r\n' +
|
||||
LINE5;
|
||||
|
||||
thisModel = Model.createFromString(text);
|
||||
thisModel = TextModel.createFromString(text);
|
||||
thisConfiguration = new TestConfiguration(null);
|
||||
thisViewModel = new ViewModel(0, thisConfiguration, thisModel, null);
|
||||
|
||||
@@ -726,7 +722,7 @@ suite('Editor Controller - Cursor', () => {
|
||||
});
|
||||
|
||||
test('issue #4905 - column select is biased to the right', () => {
|
||||
const model = Model.createFromString([
|
||||
const model = TextModel.createFromString([
|
||||
'var gulp = require("gulp");',
|
||||
'var path = require("path");',
|
||||
'var rimraf = require("rimraf");',
|
||||
@@ -762,7 +758,7 @@ suite('Editor Controller - Cursor', () => {
|
||||
});
|
||||
|
||||
test('issue #20087: column select with mouse', () => {
|
||||
const model = Model.createFromString([
|
||||
const model = TextModel.createFromString([
|
||||
'<property id="SomeThing" key="SomeKey" value="000"/>',
|
||||
'<property id="SomeThing" key="SomeKey" value="000"/>',
|
||||
'<property id="SomeThing" Key="SomeKey" value="000"/>',
|
||||
@@ -824,7 +820,7 @@ suite('Editor Controller - Cursor', () => {
|
||||
});
|
||||
|
||||
test('issue #20087: column select with keyboard', () => {
|
||||
const model = Model.createFromString([
|
||||
const model = TextModel.createFromString([
|
||||
'<property id="SomeThing" key="SomeKey" value="000"/>',
|
||||
'<property id="SomeThing" key="SomeKey" value="000"/>',
|
||||
'<property id="SomeThing" Key="SomeKey" value="000"/>',
|
||||
@@ -876,7 +872,7 @@ suite('Editor Controller - Cursor', () => {
|
||||
});
|
||||
|
||||
test('column select with keyboard', () => {
|
||||
const model = Model.createFromString([
|
||||
const model = TextModel.createFromString([
|
||||
'var gulp = require("gulp");',
|
||||
'var path = require("path");',
|
||||
'var rimraf = require("rimraf");',
|
||||
@@ -1132,7 +1128,7 @@ class IndentRulesMode extends MockMode {
|
||||
suite('Editor Controller - Regression tests', () => {
|
||||
|
||||
test('issue Microsoft/monaco-editor#443: Indentation of a single row deletes selected text in some cases', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'Hello world!',
|
||||
'another line'
|
||||
@@ -1158,7 +1154,7 @@ suite('Editor Controller - Regression tests', () => {
|
||||
});
|
||||
|
||||
test('Bug 9121: Auto indent + undo + redo is funky', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
''
|
||||
].join('\n'),
|
||||
@@ -1223,7 +1219,7 @@ suite('Editor Controller - Regression tests', () => {
|
||||
|
||||
test('bug #16815:Shift+Tab doesn\'t go back to tabstop', () => {
|
||||
let mode = new OnEnterMode(IndentAction.IndentOutdent);
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
' function baz() {'
|
||||
].join('\n'),
|
||||
@@ -1251,7 +1247,7 @@ suite('Editor Controller - Regression tests', () => {
|
||||
});
|
||||
|
||||
test('Bug #18293:[regression][editor] Can\'t outdent whitespace line', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
' '
|
||||
].join('\n'),
|
||||
@@ -1277,7 +1273,7 @@ suite('Editor Controller - Regression tests', () => {
|
||||
});
|
||||
|
||||
test('Bug #16657: [editor] Tab on empty line of zero indentation moves cursor to position (1,1)', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'function baz() {',
|
||||
'\tfunction hello() { // something here',
|
||||
@@ -1370,7 +1366,7 @@ suite('Editor Controller - Regression tests', () => {
|
||||
|
||||
test('issue #1140: Backspace stops prematurely', () => {
|
||||
let mode = new SurroundingMode();
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'function baz() {',
|
||||
' return 1;',
|
||||
@@ -1418,8 +1414,80 @@ suite('Editor Controller - Regression tests', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('issue #4996: Multiple cursor paste pastes contents of all cursors', () => {
|
||||
usingCursor({
|
||||
text: [
|
||||
'line1',
|
||||
'line2',
|
||||
'line3'
|
||||
],
|
||||
}, (model, cursor) => {
|
||||
cursor.setSelections('test', [new Selection(1, 1, 1, 1), new Selection(2, 1, 2, 1)]);
|
||||
|
||||
cursorCommand(cursor, H.Paste, {
|
||||
text: 'a\nb\nc\nd',
|
||||
pasteOnNewLine: false,
|
||||
multicursorText: [
|
||||
'a\nb',
|
||||
'c\nd'
|
||||
]
|
||||
});
|
||||
|
||||
assert.equal(model.getValue(), [
|
||||
'a',
|
||||
'bline1',
|
||||
'c',
|
||||
'dline2',
|
||||
'line3'
|
||||
].join('\n'));
|
||||
});
|
||||
});
|
||||
|
||||
test('issue #16155: Paste into multiple cursors has edge case when number of lines equals number of cursors - 1', () => {
|
||||
usingCursor({
|
||||
text: [
|
||||
'test',
|
||||
'test',
|
||||
'test',
|
||||
'test'
|
||||
],
|
||||
}, (model, cursor) => {
|
||||
cursor.setSelections('test', [
|
||||
new Selection(1, 1, 1, 5),
|
||||
new Selection(2, 1, 2, 5),
|
||||
new Selection(3, 1, 3, 5),
|
||||
new Selection(4, 1, 4, 5),
|
||||
]);
|
||||
|
||||
cursorCommand(cursor, H.Paste, {
|
||||
text: 'aaa\nbbb\nccc\n',
|
||||
pasteOnNewLine: false,
|
||||
multicursorText: null
|
||||
});
|
||||
|
||||
assert.equal(model.getValue(), [
|
||||
'aaa',
|
||||
'bbb',
|
||||
'ccc',
|
||||
'',
|
||||
'aaa',
|
||||
'bbb',
|
||||
'ccc',
|
||||
'',
|
||||
'aaa',
|
||||
'bbb',
|
||||
'ccc',
|
||||
'',
|
||||
'aaa',
|
||||
'bbb',
|
||||
'ccc',
|
||||
'',
|
||||
].join('\n'));
|
||||
});
|
||||
});
|
||||
|
||||
test('issue #3071: Investigate why undo stack gets corrupted', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'some lines',
|
||||
'and more lines',
|
||||
@@ -1499,7 +1567,7 @@ suite('Editor Controller - Regression tests', () => {
|
||||
});
|
||||
|
||||
test('issue #3463: pressing tab adds spaces, but not as many as for a tab', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'function a() {',
|
||||
'\tvar a = {',
|
||||
@@ -1526,7 +1594,7 @@ suite('Editor Controller - Regression tests', () => {
|
||||
});
|
||||
|
||||
test('issue #4312: trying to type a tab character over a sequence of spaces results in unexpected behaviour', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'var foo = 123; // this is a comment',
|
||||
'var bar = 4; // another comment'
|
||||
@@ -1630,7 +1698,7 @@ suite('Editor Controller - Regression tests', () => {
|
||||
});
|
||||
|
||||
test('issue #33788: Wrong cursor position when double click to select a word', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'Just some text'
|
||||
].join('\n')
|
||||
@@ -1784,6 +1852,88 @@ suite('Editor Controller - Regression tests', () => {
|
||||
assertCursor(cursor, new Selection(1, 12, 1, 12));
|
||||
});
|
||||
});
|
||||
|
||||
test('issue #41573 - delete across multiple lines does not shrink the selection when word wraps', () => {
|
||||
const model = TextModel.createFromString([
|
||||
'Authorization: \'Bearer pHKRfCTFSnGxs6akKlb9ddIXcca0sIUSZJutPHYqz7vEeHdMTMh0SGN0IGU3a0n59DXjTLRsj5EJ2u33qLNIFi9fk5XF8pK39PndLYUZhPt4QvHGLScgSkK0L4gwzkzMloTQPpKhqiikiIOvyNNSpd2o8j29NnOmdTUOKi9DVt74PD2ohKxyOrWZ6oZprTkb3eKajcpnS0LABKfaw2rmv4\','
|
||||
].join('\n'));
|
||||
const config = new TestConfiguration({
|
||||
wordWrap: 'wordWrapColumn',
|
||||
wordWrapColumn: 100
|
||||
});
|
||||
const viewModel = new ViewModel(0, config, model, null);
|
||||
const cursor = new Cursor(config, model, viewModel);
|
||||
|
||||
console.log(viewModel.getLineCount());
|
||||
|
||||
moveTo(cursor, 1, 43, false);
|
||||
moveTo(cursor, 1, 147, true);
|
||||
assertCursor(cursor, new Selection(1, 43, 1, 147));
|
||||
|
||||
model.applyEdits([{
|
||||
range: new Range(1, 1, 1, 43),
|
||||
text: ''
|
||||
}]);
|
||||
|
||||
assertCursor(cursor, new Selection(1, 1, 1, 105));
|
||||
|
||||
cursor.dispose();
|
||||
viewModel.dispose();
|
||||
config.dispose();
|
||||
model.dispose();
|
||||
});
|
||||
|
||||
test('issue #22717: Moving text cursor cause an incorrect position in Chinese', () => {
|
||||
// a single model line => 4 view lines
|
||||
withTestCodeEditor([
|
||||
[
|
||||
'一二三四五六七八九十',
|
||||
'12345678901234567890',
|
||||
].join('\n')
|
||||
], {}, (editor, cursor) => {
|
||||
cursor.setSelections('test', [new Selection(1, 5, 1, 5)]);
|
||||
|
||||
moveDown(cursor);
|
||||
assertCursor(cursor, new Selection(2, 9, 2, 9));
|
||||
|
||||
moveRight(cursor);
|
||||
assertCursor(cursor, new Selection(2, 10, 2, 10));
|
||||
|
||||
moveRight(cursor);
|
||||
assertCursor(cursor, new Selection(2, 11, 2, 11));
|
||||
|
||||
moveUp(cursor);
|
||||
assertCursor(cursor, new Selection(1, 6, 1, 6));
|
||||
});
|
||||
});
|
||||
|
||||
test('issue #44805: Should not be able to undo in readonly editor', () => {
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
''
|
||||
].join('\n'),
|
||||
{
|
||||
defaultEOL: DefaultEndOfLine.LF,
|
||||
detectIndentation: false,
|
||||
insertSpaces: false,
|
||||
tabSize: 4,
|
||||
trimAutoWhitespace: true
|
||||
}
|
||||
);
|
||||
|
||||
withTestCodeEditor(null, { readOnly: true, model: model }, (editor, cursor) => {
|
||||
model.pushEditOperations([new Selection(1, 1, 1, 1)], [{
|
||||
range: new Range(1, 1, 1, 1),
|
||||
text: 'Hello world!'
|
||||
}], () => [new Selection(1, 1, 1, 1)]);
|
||||
assert.equal(model.getValue(EndOfLinePreference.LF), 'Hello world!');
|
||||
|
||||
cursorCommand(cursor, H.Undo, {});
|
||||
assert.equal(model.getValue(EndOfLinePreference.LF), 'Hello world!');
|
||||
});
|
||||
|
||||
model.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
suite('Editor Controller - Cursor Configuration', () => {
|
||||
@@ -1807,7 +1957,7 @@ suite('Editor Controller - Cursor Configuration', () => {
|
||||
});
|
||||
|
||||
test('Cursor honors insertSpaces configuration on tab', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
' \tMy First Line\t ',
|
||||
'My Second Line123',
|
||||
@@ -2016,12 +2166,12 @@ suite('Editor Controller - Cursor Configuration', () => {
|
||||
|
||||
private _selectionId: string = null;
|
||||
|
||||
public getEditOperations(model: ITokenizedModel, builder: IEditOperationBuilder): void {
|
||||
public getEditOperations(model: ITextModel, builder: IEditOperationBuilder): void {
|
||||
builder.addEditOperation(new Range(1, 13, 1, 14), '');
|
||||
this._selectionId = builder.trackSelection(cursor.getSelection());
|
||||
}
|
||||
|
||||
public computeCursorState(model: ITokenizedModel, helper: ICursorStateComputerData): Selection {
|
||||
public computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection {
|
||||
return helper.getTrackedSelection(this._selectionId);
|
||||
}
|
||||
|
||||
@@ -2036,7 +2186,7 @@ suite('Editor Controller - Cursor Configuration', () => {
|
||||
});
|
||||
|
||||
test('removeAutoWhitespace on: removes only whitespace the cursor added 2', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
' if (a) {',
|
||||
' ',
|
||||
@@ -2084,7 +2234,7 @@ suite('Editor Controller - Cursor Configuration', () => {
|
||||
});
|
||||
|
||||
test('removeAutoWhitespace on: test 1', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
' some line abc '
|
||||
].join('\n'),
|
||||
@@ -2148,7 +2298,7 @@ suite('Editor Controller - Cursor Configuration', () => {
|
||||
});
|
||||
|
||||
test('UseTabStops is off', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
' x',
|
||||
' a ',
|
||||
@@ -2174,7 +2324,7 @@ suite('Editor Controller - Cursor Configuration', () => {
|
||||
});
|
||||
|
||||
test('Backspace removes whitespaces with tab size', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
' \t \t x',
|
||||
' a ',
|
||||
@@ -2247,7 +2397,7 @@ suite('Editor Controller - Cursor Configuration', () => {
|
||||
});
|
||||
|
||||
test('PR #5423: Auto indent + undo + redo is funky', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
''
|
||||
].join('\n'),
|
||||
@@ -2413,7 +2563,7 @@ suite('Editor Controller - Indentation Rules', () => {
|
||||
});
|
||||
|
||||
test('Enter honors indentNextLinePattern 2', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'if (true)',
|
||||
'\tif (true)'
|
||||
@@ -2888,7 +3038,7 @@ suite('Editor Controller - Indentation Rules', () => {
|
||||
});
|
||||
|
||||
test('bug #16543: Tab should indent to correct indentation spot immediately', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'function baz() {',
|
||||
'\tfunction hello() { // something here',
|
||||
@@ -2920,7 +3070,7 @@ suite('Editor Controller - Indentation Rules', () => {
|
||||
|
||||
|
||||
test('bug #2938 (1): When pressing Tab on white-space only lines, indent straight to the right spot (similar to empty lines)', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'\tfunction baz() {',
|
||||
'\t\tfunction hello() { // something here',
|
||||
@@ -2952,7 +3102,7 @@ suite('Editor Controller - Indentation Rules', () => {
|
||||
|
||||
|
||||
test('bug #2938 (2): When pressing Tab on white-space only lines, indent straight to the right spot (similar to empty lines)', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'\tfunction baz() {',
|
||||
'\t\tfunction hello() { // something here',
|
||||
@@ -2983,7 +3133,7 @@ suite('Editor Controller - Indentation Rules', () => {
|
||||
});
|
||||
|
||||
test('bug #2938 (3): When pressing Tab on white-space only lines, indent straight to the right spot (similar to empty lines)', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'\tfunction baz() {',
|
||||
'\t\tfunction hello() { // something here',
|
||||
@@ -3014,7 +3164,7 @@ suite('Editor Controller - Indentation Rules', () => {
|
||||
});
|
||||
|
||||
test('bug #2938 (4): When pressing Tab on white-space only lines, indent straight to the right spot (similar to empty lines)', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'\tfunction baz() {',
|
||||
'\t\tfunction hello() { // something here',
|
||||
@@ -3046,7 +3196,7 @@ suite('Editor Controller - Indentation Rules', () => {
|
||||
|
||||
test('bug #31015: When pressing Tab on lines and Enter rules are avail, indent straight to the right spotTab', () => {
|
||||
let mode = new OnEnterMode(IndentAction.Indent);
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
' if (a) {',
|
||||
' ',
|
||||
@@ -3083,7 +3233,7 @@ suite('Editor Controller - Indentation Rules', () => {
|
||||
increaseIndentPattern: /^\s*((begin|class|def|else|elsif|ensure|for|if|module|rescue|unless|until|when|while)|(.*\sdo\b))\b[^\{;]*$/,
|
||||
decreaseIndentPattern: /^\s*([}\]]([,)]?\s*(#|$)|\.[a-zA-Z_]\w*\b)|(end|rescue|ensure|else|elsif|when)\b)/
|
||||
});
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'class Greeter',
|
||||
' def initialize(name)',
|
||||
@@ -3222,7 +3372,7 @@ suite('Editor Controller - Indentation Rules', () => {
|
||||
}
|
||||
|
||||
let mode = new JSMode();
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'class ItemCtrl {',
|
||||
' getPropertiesByItemId(id) {',
|
||||
@@ -3282,7 +3432,7 @@ suite('Editor Controller - Indentation Rules', () => {
|
||||
}
|
||||
|
||||
let mode = new CppMode();
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'int main() {',
|
||||
' return 0;',
|
||||
@@ -3331,8 +3481,8 @@ interface ICursorOpts {
|
||||
editorOpts?: IEditorOptions;
|
||||
}
|
||||
|
||||
function usingCursor(opts: ICursorOpts, callback: (model: Model, cursor: Cursor) => void): void {
|
||||
let model = Model.createFromString(opts.text.join('\n'), opts.modelOpts, opts.languageIdentifier);
|
||||
function usingCursor(opts: ICursorOpts, callback: (model: TextModel, cursor: Cursor) => void): void {
|
||||
let model = TextModel.createFromString(opts.text.join('\n'), opts.modelOpts, opts.languageIdentifier);
|
||||
model.forceTokenization(model.getLineCount());
|
||||
let config = new TestConfiguration(opts.editorOpts);
|
||||
let viewModel = new ViewModel(0, config, model, null);
|
||||
@@ -3648,7 +3798,7 @@ suite('autoClosingPairs', () => {
|
||||
return result;
|
||||
}
|
||||
|
||||
function assertType(model: Model, cursor: Cursor, lineNumber: number, column: number, chr: string, expectedInsert: string, message: string): void {
|
||||
function assertType(model: TextModel, cursor: Cursor, lineNumber: number, column: number, chr: string, expectedInsert: string, message: string): void {
|
||||
let lineContent = model.getLineContent(lineNumber);
|
||||
let expected = lineContent.substr(0, column - 1) + expectedInsert + lineContent.substr(column - 1);
|
||||
moveTo(cursor, lineNumber, column);
|
||||
@@ -3894,7 +4044,7 @@ suite('autoClosingPairs', () => {
|
||||
|
||||
test('All cursors should do the same thing when deleting left', () => {
|
||||
let mode = new AutoClosingMode();
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'var a = ()'
|
||||
].join('\n'),
|
||||
@@ -3918,7 +4068,7 @@ suite('autoClosingPairs', () => {
|
||||
});
|
||||
|
||||
test('issue #7100: Mouse word selection is strange when non-word character is at the end of line', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'before.a',
|
||||
'before',
|
||||
@@ -3948,7 +4098,7 @@ suite('autoClosingPairs', () => {
|
||||
suite('Undo stops', () => {
|
||||
|
||||
test('there is an undo stop between typing and deleting left', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'A line',
|
||||
'Another line',
|
||||
@@ -3977,7 +4127,7 @@ suite('Undo stops', () => {
|
||||
});
|
||||
|
||||
test('there is an undo stop between typing and deleting right', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'A line',
|
||||
'Another line',
|
||||
@@ -4006,7 +4156,7 @@ suite('Undo stops', () => {
|
||||
});
|
||||
|
||||
test('there is an undo stop between deleting left and typing', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'A line',
|
||||
'Another line',
|
||||
@@ -4040,7 +4190,7 @@ suite('Undo stops', () => {
|
||||
});
|
||||
|
||||
test('there is an undo stop between deleting left and deleting right', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'A line',
|
||||
'Another line',
|
||||
@@ -4078,7 +4228,7 @@ suite('Undo stops', () => {
|
||||
});
|
||||
|
||||
test('there is an undo stop between deleting right and typing', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'A line',
|
||||
'Another line',
|
||||
@@ -4109,7 +4259,7 @@ suite('Undo stops', () => {
|
||||
});
|
||||
|
||||
test('there is an undo stop between deleting right and deleting left', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'A line',
|
||||
'Another line',
|
||||
@@ -4145,7 +4295,7 @@ suite('Undo stops', () => {
|
||||
});
|
||||
|
||||
test('inserts undo stop when typing space', () => {
|
||||
let model = Model.createFromString(
|
||||
let model = TextModel.createFromString(
|
||||
[
|
||||
'A line',
|
||||
'Another line',
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import * as assert from 'assert';
|
||||
import { Cursor } from 'vs/editor/common/controller/cursor';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Model } from 'vs/editor/common/model/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration';
|
||||
import { CursorMove } from 'vs/editor/common/controller/cursorMoveCommands';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
@@ -17,7 +17,7 @@ import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl';
|
||||
|
||||
suite('Cursor move command test', () => {
|
||||
|
||||
let thisModel: Model;
|
||||
let thisModel: TextModel;
|
||||
let thisConfiguration: TestConfiguration;
|
||||
let thisViewModel: ViewModel;
|
||||
let thisCursor: Cursor;
|
||||
@@ -31,7 +31,7 @@ suite('Cursor move command test', () => {
|
||||
'1'
|
||||
].join('\n');
|
||||
|
||||
thisModel = Model.createFromString(text);
|
||||
thisModel = TextModel.createFromString(text);
|
||||
thisConfiguration = new TestConfiguration(null);
|
||||
thisViewModel = new ViewModel(0, thisConfiguration, thisModel, null);
|
||||
thisCursor = new Cursor(thisConfiguration, thisModel, thisViewModel);
|
||||
|
||||
@@ -8,9 +8,9 @@ import { TextAreaInput, ITextAreaInputHost } from 'vs/editor/browser/controller/
|
||||
import { ISimpleModel, TextAreaState, PagedScreenReaderStrategy } from 'vs/editor/browser/controller/textAreaState';
|
||||
import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { createFastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import * as browser from 'vs/base/browser/browser';
|
||||
import { EndOfLinePreference } from 'vs/editor/common/model';
|
||||
|
||||
// To run this test, open imeTester.html
|
||||
|
||||
@@ -30,7 +30,7 @@ class SingleLineTestModel implements ISimpleModel {
|
||||
return this._line.length + 1;
|
||||
}
|
||||
|
||||
getValueInRange(range: IRange, eol: editorCommon.EndOfLinePreference): string {
|
||||
getValueInRange(range: IRange, eol: EndOfLinePreference): string {
|
||||
return this._line.substring(range.startColumn - 1, range.endColumn - 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as assert from 'assert';
|
||||
import { TextAreaState, ITextAreaWrapper, PagedScreenReaderStrategy } from 'vs/editor/browser/controller/textAreaState';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Model } from 'vs/editor/common/model/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
|
||||
export class MockTextAreaWrapper extends Disposable implements ITextAreaWrapper {
|
||||
@@ -507,7 +507,7 @@ suite('TextAreaState', () => {
|
||||
suite('PagedScreenReaderStrategy', () => {
|
||||
|
||||
function testPagedScreenReaderStrategy(lines: string[], selection: Selection, expected: TextAreaState): void {
|
||||
const model = Model.createFromString(lines.join('\n'));
|
||||
const model = TextModel.createFromString(lines.join('\n'));
|
||||
const actual = PagedScreenReaderStrategy.fromEditorSelection(TextAreaState.EMPTY, model, selection, true);
|
||||
assert.ok(equalsTextAreaState(actual, expected));
|
||||
model.dispose();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IModel } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { EditorState, CodeEditorStateFlag } from 'vs/editor/browser/core/editorState';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
@@ -93,7 +93,7 @@ suite('Editor Core - Editor State', () => {
|
||||
let mappedModel = model ? { uri: model.uri ? model.uri : URI.parse('http://dummy.org'), getVersionId: () => model.version } : null;
|
||||
|
||||
return {
|
||||
getModel: (): IModel => <any>mappedModel,
|
||||
getModel: (): ITextModel => <any>mappedModel,
|
||||
getPosition: (): Position => position,
|
||||
getSelection: (): Selection => selection,
|
||||
getScrollLeft: (): number => scroll && scroll.left,
|
||||
|
||||
@@ -15,6 +15,5 @@ const themeServiceMock = new TestThemeService();
|
||||
|
||||
suite('Decoration Render Options', () => {
|
||||
test('register and resolve decoration type', () => {
|
||||
assert.notEqual(true, false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ import { CommonEditorConfiguration } from 'vs/editor/common/config/commonEditorC
|
||||
import { Cursor } from 'vs/editor/common/controller/cursor';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import * as editorBrowser from 'vs/editor/browser/editorBrowser';
|
||||
import { Model } from 'vs/editor/common/model/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration';
|
||||
import * as editorOptions from 'vs/editor/common/config/editorOptions';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
@@ -23,6 +23,7 @@ import { IPosition } from 'vs/editor/common/core/position';
|
||||
import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { IModelDecorationOptions, ITextModel } from 'vs/editor/common/model';
|
||||
|
||||
export class TestCodeEditor extends CommonCodeEditor implements editorBrowser.ICodeEditor {
|
||||
|
||||
@@ -77,7 +78,7 @@ export class TestCodeEditor extends CommonCodeEditor implements editorBrowser.IC
|
||||
|
||||
protected _registerDecorationType(key: string, options: editorCommon.IDecorationRenderOptions, parentTypeKey?: string): void { throw new Error('NotImplemented'); }
|
||||
protected _removeDecorationType(key: string): void { throw new Error('NotImplemented'); }
|
||||
protected _resolveDecorationOptions(typeKey: string, writable: boolean): editorCommon.IModelDecorationOptions { throw new Error('NotImplemented'); }
|
||||
protected _resolveDecorationOptions(typeKey: string, writable: boolean): IModelDecorationOptions { throw new Error('NotImplemented'); }
|
||||
|
||||
// --- test utils
|
||||
getCursor(): Cursor {
|
||||
@@ -139,15 +140,15 @@ export interface TestCodeEditorCreationOptions extends editorOptions.IEditorOpti
|
||||
/**
|
||||
* The initial model associated with this code editor.
|
||||
*/
|
||||
model?: editorCommon.IModel;
|
||||
model?: ITextModel;
|
||||
serviceCollection?: ServiceCollection;
|
||||
}
|
||||
|
||||
export function withTestCodeEditor(text: string[], options: TestCodeEditorCreationOptions, callback: (editor: TestCodeEditor, cursor: Cursor) => void): void {
|
||||
// create a model if necessary and remember it in order to dispose it.
|
||||
let modelToDispose: Model = null;
|
||||
let modelToDispose: TextModel = null;
|
||||
if (!options.model) {
|
||||
modelToDispose = Model.createFromString(text.join('\n'));
|
||||
modelToDispose = TextModel.createFromString(text.join('\n'));
|
||||
options.model = modelToDispose;
|
||||
}
|
||||
|
||||
@@ -160,7 +161,7 @@ export function withTestCodeEditor(text: string[], options: TestCodeEditorCreati
|
||||
editor.dispose();
|
||||
}
|
||||
|
||||
export function createTestCodeEditor(model: editorCommon.IModel): TestCodeEditor {
|
||||
export function createTestCodeEditor(model: ITextModel): TestCodeEditor {
|
||||
return _createTestCodeEditor({ model: model });
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { IDecorationRenderOptions, IModelDecorationOptions } from 'vs/editor/common/editorCommon';
|
||||
import { IModelDecorationOptions } from 'vs/editor/common/model';
|
||||
import { IDecorationRenderOptions } from 'vs/editor/common/editorCommon';
|
||||
import { AbstractCodeEditorService } from 'vs/editor/browser/services/abstractCodeEditorService';
|
||||
|
||||
export class TestCodeEditorService extends AbstractCodeEditorService {
|
||||
|
||||
@@ -8,9 +8,10 @@ import * as assert from 'assert';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { Model } from 'vs/editor/common/model/model';
|
||||
import { TextModel } from 'vs/editor/common/model/textModel';
|
||||
import { LanguageIdentifier } from 'vs/editor/common/modes';
|
||||
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { ITextModel, IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
|
||||
|
||||
export function testCommand(
|
||||
lines: string[],
|
||||
@@ -20,7 +21,7 @@ export function testCommand(
|
||||
expectedLines: string[],
|
||||
expectedSelection: Selection
|
||||
): void {
|
||||
let model = Model.createFromString(lines.join('\n'), undefined, languageIdentifier);
|
||||
let model = TextModel.createFromString(lines.join('\n'), undefined, languageIdentifier);
|
||||
withTestCodeEditor(null, { model: model }, (editor, cursor) => {
|
||||
|
||||
cursor.setSelections('tests', [selection]);
|
||||
@@ -39,24 +40,20 @@ export function testCommand(
|
||||
/**
|
||||
* Extract edit operations if command `command` were to execute on model `model`
|
||||
*/
|
||||
export function getEditOperation(model: editorCommon.IModel, command: editorCommon.ICommand): editorCommon.IIdentifiedSingleEditOperation[] {
|
||||
var operations: editorCommon.IIdentifiedSingleEditOperation[] = [];
|
||||
export function getEditOperation(model: ITextModel, command: editorCommon.ICommand): IIdentifiedSingleEditOperation[] {
|
||||
var operations: IIdentifiedSingleEditOperation[] = [];
|
||||
var editOperationBuilder: editorCommon.IEditOperationBuilder = {
|
||||
addEditOperation: (range: Range, text: string) => {
|
||||
operations.push({
|
||||
identifier: null,
|
||||
range: range,
|
||||
text: text,
|
||||
forceMoveMarkers: false
|
||||
text: text
|
||||
});
|
||||
},
|
||||
|
||||
addTrackedEditOperation: (range: Range, text: string) => {
|
||||
operations.push({
|
||||
identifier: null,
|
||||
range: range,
|
||||
text: text,
|
||||
forceMoveMarkers: false
|
||||
text: text
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user