Merge VS Code 1.31.1 (#4283)

This commit is contained in:
Matt Irvine
2019-03-15 13:09:45 -07:00
committed by GitHub
parent 7d31575149
commit 86bac90001
1716 changed files with 53308 additions and 48375 deletions

View File

@@ -38,11 +38,11 @@ abstract class AbstractCopyLinesAction extends EditorAction {
public run(_accessor: ServicesAccessor, editor: ICodeEditor): void {
let commands: ICommand[] = [];
let selections = editor.getSelections() || [];
const commands: ICommand[] = [];
const selections = editor.getSelections() || [];
for (let i = 0; i < selections.length; i++) {
commands.push(new CopyLinesCommand(selections[i], this.down));
for (const selection of selections) {
commands.push(new CopyLinesCommand(selection, this.down));
}
editor.pushUndoStop();
@@ -114,8 +114,8 @@ abstract class AbstractMoveLinesAction extends EditorAction {
let selections = editor.getSelections() || [];
let autoIndent = editor.getConfiguration().autoIndent;
for (let i = 0; i < selections.length; i++) {
commands.push(new MoveLinesCommand(selections[i], this.down, autoIndent));
for (const selection of selections) {
commands.push(new MoveLinesCommand(selection, this.down, autoIndent));
}
editor.pushUndoStop();
@@ -181,8 +181,7 @@ export abstract class AbstractSortLinesAction extends EditorAction {
public run(_accessor: ServicesAccessor, editor: ICodeEditor): void {
const selections = editor.getSelections() || [];
for (let i = 0, len = selections.length; i < len; i++) {
const selection = selections[i];
for (const selection of selections) {
if (!SortLinesCommand.canRun(editor.getModel(), selection, this.descending)) {
return;
}

View File

@@ -21,18 +21,18 @@ suite('Editor Contrib - Line Operations', () => {
'omicron',
'beta',
'alpha'
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let sortLinesAscendingAction = new SortLinesAscendingAction();
editor.setSelection(new Selection(1, 1, 3, 5));
sortLinesAscendingAction.run(null, editor);
sortLinesAscendingAction.run(null!, editor);
assert.deepEqual(model.getLinesContent(), [
'alpha',
'beta',
'omicron'
]);
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 3, 7).toString());
assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 1, 3, 7).toString());
});
});
@@ -46,12 +46,12 @@ suite('Editor Contrib - Line Operations', () => {
'omicron',
'beta',
'alpha'
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let sortLinesAscendingAction = new SortLinesAscendingAction();
editor.setSelections([new Selection(1, 1, 3, 5), new Selection(5, 1, 7, 5)]);
sortLinesAscendingAction.run(null, editor);
sortLinesAscendingAction.run(null!, editor);
assert.deepEqual(model.getLinesContent(), [
'alpha',
'beta',
@@ -65,7 +65,7 @@ suite('Editor Contrib - Line Operations', () => {
new Selection(1, 1, 3, 7),
new Selection(5, 1, 7, 7)
];
editor.getSelections().forEach((actualSelection, index) => {
editor.getSelections()!.forEach((actualSelection, index) => {
assert.deepEqual(actualSelection.toString(), expectedSelections[index].toString());
});
});
@@ -79,18 +79,18 @@ suite('Editor Contrib - Line Operations', () => {
'alpha',
'beta',
'omicron'
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let sortLinesDescendingAction = new SortLinesDescendingAction();
editor.setSelection(new Selection(1, 1, 3, 7));
sortLinesDescendingAction.run(null, editor);
sortLinesDescendingAction.run(null!, editor);
assert.deepEqual(model.getLinesContent(), [
'omicron',
'beta',
'alpha'
]);
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 3, 5).toString());
assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 1, 3, 5).toString());
});
});
@@ -104,12 +104,12 @@ suite('Editor Contrib - Line Operations', () => {
'alpha',
'beta',
'omicron'
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let sortLinesDescendingAction = new SortLinesDescendingAction();
editor.setSelections([new Selection(1, 1, 3, 7), new Selection(5, 1, 7, 7)]);
sortLinesDescendingAction.run(null, editor);
sortLinesDescendingAction.run(null!, editor);
assert.deepEqual(model.getLinesContent(), [
'omicron',
'beta',
@@ -123,7 +123,7 @@ suite('Editor Contrib - Line Operations', () => {
new Selection(1, 1, 3, 5),
new Selection(5, 1, 7, 5)
];
editor.getSelections().forEach((actualSelection, index) => {
editor.getSelections()!.forEach((actualSelection, index) => {
assert.deepEqual(actualSelection.toString(), expectedSelections[index].toString());
});
});
@@ -138,16 +138,16 @@ suite('Editor Contrib - Line Operations', () => {
'one',
'two',
'three'
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let deleteAllLeftAction = new DeleteAllLeftAction();
editor.setSelection(new Selection(1, 2, 1, 2));
deleteAllLeftAction.run(null, editor);
deleteAllLeftAction.run(null!, editor);
assert.equal(model.getLineContent(1), 'ne', '001');
editor.setSelections([new Selection(2, 2, 2, 2), new Selection(3, 2, 3, 2)]);
deleteAllLeftAction.run(null, editor);
deleteAllLeftAction.run(null!, editor);
assert.equal(model.getLineContent(2), 'wo', '002');
assert.equal(model.getLineContent(3), 'hree', '003');
});
@@ -159,21 +159,21 @@ suite('Editor Contrib - Line Operations', () => {
'one',
'two',
'three'
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let deleteAllLeftAction = new DeleteAllLeftAction();
editor.setSelection(new Selection(2, 1, 2, 1));
deleteAllLeftAction.run(null, editor);
deleteAllLeftAction.run(null!, editor);
assert.equal(model.getLineContent(1), 'onetwo', '001');
editor.setSelections([new Selection(1, 1, 1, 1), new Selection(2, 1, 2, 1)]);
deleteAllLeftAction.run(null, editor);
deleteAllLeftAction.run(null!, editor);
assert.equal(model.getLinesContent()[0], 'onetwothree');
assert.equal(model.getLinesContent().length, 1);
editor.setSelection(new Selection(1, 1, 1, 1));
deleteAllLeftAction.run(null, editor);
deleteAllLeftAction.run(null!, editor);
assert.equal(model.getLinesContent()[0], 'onetwothree');
});
});
@@ -187,8 +187,8 @@ suite('Editor Contrib - Line Operations', () => {
'my wife doesnt believe in me',
'nonononono',
'bitconneeeect'
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let deleteAllLeftAction = new DeleteAllLeftAction();
const beforeSecondWasoSelection = new Selection(3, 5, 3, 5);
@@ -198,7 +198,7 @@ suite('Editor Contrib - Line Operations', () => {
editor.setSelections([beforeSecondWasoSelection, endOfBCCSelection, endOfNonono]);
let selections;
deleteAllLeftAction.run(null, editor);
deleteAllLeftAction.run(null!, editor);
selections = editor.getSelections();
assert.equal(model.getLineContent(2), '');
@@ -226,7 +226,7 @@ suite('Editor Contrib - Line Operations', () => {
selections[2].endColumn
], [5, 1, 5, 1]);
deleteAllLeftAction.run(null, editor);
deleteAllLeftAction.run(null!, editor);
selections = editor.getSelections();
assert.equal(model.getLineContent(1), 'hi my name is Carlos Matos waso waso');
@@ -259,28 +259,28 @@ suite('Editor Contrib - Line Operations', () => {
'hola',
'world',
'hello world',
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let deleteAllLeftAction = new DeleteAllLeftAction();
editor.setSelections([new Selection(1, 2, 1, 2), new Selection(1, 4, 1, 4)]);
deleteAllLeftAction.run(null, editor);
deleteAllLeftAction.run(null!, editor);
assert.equal(model.getLineContent(1), 'lo', '001');
editor.setSelections([new Selection(2, 2, 2, 2), new Selection(2, 4, 2, 5)]);
deleteAllLeftAction.run(null, editor);
deleteAllLeftAction.run(null!, editor);
assert.equal(model.getLineContent(2), 'ord', '002');
editor.setSelections([new Selection(3, 2, 3, 5), new Selection(3, 7, 3, 7)]);
deleteAllLeftAction.run(null, editor);
deleteAllLeftAction.run(null!, editor);
assert.equal(model.getLineContent(3), 'world', '003');
editor.setSelections([new Selection(4, 3, 4, 3), new Selection(4, 5, 5, 4)]);
deleteAllLeftAction.run(null, editor);
deleteAllLeftAction.run(null!, editor);
assert.equal(model.getLineContent(4), 'lljour', '004');
editor.setSelections([new Selection(5, 3, 6, 3), new Selection(6, 5, 7, 5), new Selection(7, 7, 7, 7)]);
deleteAllLeftAction.run(null, editor);
deleteAllLeftAction.run(null!, editor);
assert.equal(model.getLineContent(5), 'horlworld', '005');
});
});
@@ -291,8 +291,8 @@ suite('Editor Contrib - Line Operations', () => {
'one',
'two',
'three'
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let deleteAllLeftAction = new DeleteAllLeftAction();
editor.setSelection(new Selection(1, 1, 1, 1));
@@ -301,7 +301,7 @@ suite('Editor Contrib - Line Operations', () => {
assert.equal(model.getLineContent(1), 'Typing some text here on line one');
assert.deepEqual(editor.getSelection(), new Selection(1, 31, 1, 31));
deleteAllLeftAction.run(null, editor);
deleteAllLeftAction.run(null!, editor);
assert.equal(model.getLineContent(1), 'one');
assert.deepEqual(editor.getSelection(), new Selection(1, 1, 1, 1));
@@ -327,34 +327,34 @@ suite('Editor Contrib - Line Operations', () => {
'',
'',
'hello world'
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let joinLinesAction = new JoinLinesAction();
editor.setSelection(new Selection(1, 2, 1, 2));
joinLinesAction.run(null, editor);
joinLinesAction.run(null!, editor);
assert.equal(model.getLineContent(1), 'hello world', '001');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 6, 1, 6).toString(), '002');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 6, 1, 6).toString(), '002');
editor.setSelection(new Selection(2, 2, 2, 2));
joinLinesAction.run(null, editor);
joinLinesAction.run(null!, editor);
assert.equal(model.getLineContent(2), 'hello world', '003');
assert.deepEqual(editor.getSelection().toString(), new Selection(2, 7, 2, 7).toString(), '004');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 7, 2, 7).toString(), '004');
editor.setSelection(new Selection(3, 2, 3, 2));
joinLinesAction.run(null, editor);
joinLinesAction.run(null!, editor);
assert.equal(model.getLineContent(3), 'hello world', '005');
assert.deepEqual(editor.getSelection().toString(), new Selection(3, 7, 3, 7).toString(), '006');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(3, 7, 3, 7).toString(), '006');
editor.setSelection(new Selection(4, 2, 5, 3));
joinLinesAction.run(null, editor);
joinLinesAction.run(null!, editor);
assert.equal(model.getLineContent(4), 'hello world', '007');
assert.deepEqual(editor.getSelection().toString(), new Selection(4, 2, 4, 8).toString(), '008');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(4, 2, 4, 8).toString(), '008');
editor.setSelection(new Selection(5, 1, 7, 3));
joinLinesAction.run(null, editor);
joinLinesAction.run(null!, editor);
assert.equal(model.getLineContent(5), 'hello world', '009');
assert.deepEqual(editor.getSelection().toString(), new Selection(5, 1, 5, 3).toString(), '010');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(5, 1, 5, 3).toString(), '010');
});
});
@@ -363,15 +363,15 @@ suite('Editor Contrib - Line Operations', () => {
[
'hello',
'world'
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let joinLinesAction = new JoinLinesAction();
editor.setSelection(new Selection(2, 1, 2, 1));
joinLinesAction.run(null, editor);
joinLinesAction.run(null!, editor);
assert.equal(model.getLineContent(1), 'hello', '001');
assert.equal(model.getLineContent(2), 'world', '002');
assert.deepEqual(editor.getSelection().toString(), new Selection(2, 6, 2, 6).toString(), '003');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 6, 2, 6).toString(), '003');
});
});
@@ -389,8 +389,8 @@ suite('Editor Contrib - Line Operations', () => {
'',
'',
'hello world'
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let joinLinesAction = new JoinLinesAction();
editor.setSelections([
@@ -403,9 +403,9 @@ suite('Editor Contrib - Line Operations', () => {
new Selection(10, 1, 10, 1)
]);
joinLinesAction.run(null, editor);
joinLinesAction.run(null!, editor);
assert.equal(model.getLinesContent().join('\n'), 'hello world\nhello world\nhello world\nhello world\n\nhello world', '001');
assert.deepEqual(editor.getSelections().toString(), [
assert.deepEqual(editor.getSelections()!.toString(), [
/** primary cursor */
new Selection(3, 4, 3, 8),
new Selection(1, 6, 1, 6),
@@ -415,7 +415,7 @@ suite('Editor Contrib - Line Operations', () => {
].toString(), '002');
/** primary cursor */
assert.deepEqual(editor.getSelection().toString(), new Selection(3, 4, 3, 8).toString(), '003');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(3, 4, 3, 8).toString(), '003');
});
});
@@ -424,8 +424,8 @@ suite('Editor Contrib - Line Operations', () => {
[
'hello',
'world'
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let joinLinesAction = new JoinLinesAction();
editor.setSelection(new Selection(1, 6, 1, 6));
@@ -434,7 +434,7 @@ suite('Editor Contrib - Line Operations', () => {
assert.equal(model.getLineContent(1), 'hello my dear');
assert.deepEqual(editor.getSelection(), new Selection(1, 14, 1, 14));
joinLinesAction.run(null, editor);
joinLinesAction.run(null!, editor);
assert.equal(model.getLineContent(1), 'hello my dear world');
assert.deepEqual(editor.getSelection(), new Selection(1, 14, 1, 14));
@@ -452,34 +452,34 @@ suite('Editor Contrib - Line Operations', () => {
'',
'',
' ',
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let transposeAction = new TransposeAction();
editor.setSelection(new Selection(1, 1, 1, 1));
transposeAction.run(null, editor);
transposeAction.run(null!, editor);
assert.equal(model.getLineContent(1), 'hello world', '001');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 2, 1, 2).toString(), '002');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 2, 1, 2).toString(), '002');
editor.setSelection(new Selection(1, 6, 1, 6));
transposeAction.run(null, editor);
transposeAction.run(null!, editor);
assert.equal(model.getLineContent(1), 'hell oworld', '003');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 7, 1, 7).toString(), '004');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 7, 1, 7).toString(), '004');
editor.setSelection(new Selection(1, 12, 1, 12));
transposeAction.run(null, editor);
transposeAction.run(null!, editor);
assert.equal(model.getLineContent(1), 'hell oworl', '005');
assert.deepEqual(editor.getSelection().toString(), new Selection(2, 2, 2, 2).toString(), '006');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 2, 2, 2).toString(), '006');
editor.setSelection(new Selection(3, 1, 3, 1));
transposeAction.run(null, editor);
transposeAction.run(null!, editor);
assert.equal(model.getLineContent(3), '', '007');
assert.deepEqual(editor.getSelection().toString(), new Selection(4, 1, 4, 1).toString(), '008');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(4, 1, 4, 1).toString(), '008');
editor.setSelection(new Selection(4, 2, 4, 2));
transposeAction.run(null, editor);
transposeAction.run(null!, editor);
assert.equal(model.getLineContent(4), ' ', '009');
assert.deepEqual(editor.getSelection().toString(), new Selection(4, 3, 4, 3).toString(), '010');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(4, 3, 4, 3).toString(), '010');
}
);
@@ -494,29 +494,29 @@ suite('Editor Contrib - Line Operations', () => {
'hello world',
'',
'hello world'
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let transposeAction = new TransposeAction();
editor.setSelection(new Selection(1, 1, 1, 1));
transposeAction.run(null, editor);
transposeAction.run(null!, editor);
assert.equal(model.getLineContent(2), '', '011');
assert.deepEqual(editor.getSelection().toString(), new Selection(2, 1, 2, 1).toString(), '012');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 1, 2, 1).toString(), '012');
editor.setSelection(new Selection(3, 6, 3, 6));
transposeAction.run(null, editor);
transposeAction.run(null!, editor);
assert.equal(model.getLineContent(4), 'oworld', '013');
assert.deepEqual(editor.getSelection().toString(), new Selection(4, 2, 4, 2).toString(), '014');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(4, 2, 4, 2).toString(), '014');
editor.setSelection(new Selection(6, 12, 6, 12));
transposeAction.run(null, editor);
transposeAction.run(null!, editor);
assert.equal(model.getLineContent(7), 'd', '015');
assert.deepEqual(editor.getSelection().toString(), new Selection(7, 2, 7, 2).toString(), '016');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(7, 2, 7, 2).toString(), '016');
editor.setSelection(new Selection(8, 12, 8, 12));
transposeAction.run(null, editor);
transposeAction.run(null!, editor);
assert.equal(model.getLineContent(8), 'hello world', '019');
assert.deepEqual(editor.getSelection().toString(), new Selection(8, 12, 8, 12).toString(), '020');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(8, 12, 8, 12).toString(), '020');
}
);
});
@@ -526,40 +526,40 @@ suite('Editor Contrib - Line Operations', () => {
[
'hello world',
'öçşğü'
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let uppercaseAction = new UpperCaseAction();
let lowercaseAction = new LowerCaseAction();
editor.setSelection(new Selection(1, 1, 1, 12));
uppercaseAction.run(null, editor);
uppercaseAction.run(null!, editor);
assert.equal(model.getLineContent(1), 'HELLO WORLD', '001');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 1, 12).toString(), '002');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 1, 1, 12).toString(), '002');
editor.setSelection(new Selection(1, 1, 1, 12));
lowercaseAction.run(null, editor);
lowercaseAction.run(null!, editor);
assert.equal(model.getLineContent(1), 'hello world', '003');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 1, 12).toString(), '004');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 1, 1, 12).toString(), '004');
editor.setSelection(new Selection(1, 3, 1, 3));
uppercaseAction.run(null, editor);
uppercaseAction.run(null!, editor);
assert.equal(model.getLineContent(1), 'HELLO world', '005');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 3, 1, 3).toString(), '006');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 3, 1, 3).toString(), '006');
editor.setSelection(new Selection(1, 4, 1, 4));
lowercaseAction.run(null, editor);
lowercaseAction.run(null!, editor);
assert.equal(model.getLineContent(1), 'hello world', '007');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 4, 1, 4).toString(), '008');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 4, 1, 4).toString(), '008');
editor.setSelection(new Selection(2, 1, 2, 6));
uppercaseAction.run(null, editor);
uppercaseAction.run(null!, editor);
assert.equal(model.getLineContent(2), 'ÖÇŞĞÜ', '009');
assert.deepEqual(editor.getSelection().toString(), new Selection(2, 1, 2, 6).toString(), '010');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 1, 2, 6).toString(), '010');
editor.setSelection(new Selection(2, 1, 2, 6));
lowercaseAction.run(null, editor);
lowercaseAction.run(null!, editor);
assert.equal(model.getLineContent(2), 'öçşğü', '011');
assert.deepEqual(editor.getSelection().toString(), new Selection(2, 1, 2, 6).toString(), '012');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 1, 2, 6).toString(), '012');
}
);
@@ -567,51 +567,51 @@ suite('Editor Contrib - Line Operations', () => {
[
'',
' '
], {}, (editor, cursor) => {
let model = editor.getModel();
], {}, (editor) => {
let model = editor.getModel()!;
let uppercaseAction = new UpperCaseAction();
let lowercaseAction = new LowerCaseAction();
editor.setSelection(new Selection(1, 1, 1, 1));
uppercaseAction.run(null, editor);
uppercaseAction.run(null!, editor);
assert.equal(model.getLineContent(1), '', '013');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 1, 1).toString(), '014');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 1, 1, 1).toString(), '014');
editor.setSelection(new Selection(1, 1, 1, 1));
lowercaseAction.run(null, editor);
lowercaseAction.run(null!, editor);
assert.equal(model.getLineContent(1), '', '015');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 1, 1).toString(), '016');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(1, 1, 1, 1).toString(), '016');
editor.setSelection(new Selection(2, 2, 2, 2));
uppercaseAction.run(null, editor);
uppercaseAction.run(null!, editor);
assert.equal(model.getLineContent(2), ' ', '017');
assert.deepEqual(editor.getSelection().toString(), new Selection(2, 2, 2, 2).toString(), '018');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 2, 2, 2).toString(), '018');
editor.setSelection(new Selection(2, 2, 2, 2));
lowercaseAction.run(null, editor);
lowercaseAction.run(null!, editor);
assert.equal(model.getLineContent(2), ' ', '019');
assert.deepEqual(editor.getSelection().toString(), new Selection(2, 2, 2, 2).toString(), '020');
assert.deepEqual(editor.getSelection()!.toString(), new Selection(2, 2, 2, 2).toString(), '020');
}
);
});
suite('DeleteAllRightAction', () => {
test('should be noop on empty', () => {
withTestCodeEditor([''], {}, (editor, cursor) => {
const model = editor.getModel();
withTestCodeEditor([''], {}, (editor) => {
const model = editor.getModel()!;
const action = new DeleteAllRightAction();
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['']);
assert.deepEqual(editor.getSelections(), [new Selection(1, 1, 1, 1)]);
editor.setSelection(new Selection(1, 1, 1, 1));
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['']);
assert.deepEqual(editor.getSelections(), [new Selection(1, 1, 1, 1)]);
editor.setSelections([new Selection(1, 1, 1, 1), new Selection(1, 1, 1, 1), new Selection(1, 1, 1, 1)]);
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['']);
assert.deepEqual(editor.getSelections(), [new Selection(1, 1, 1, 1)]);
});
@@ -621,22 +621,22 @@ suite('Editor Contrib - Line Operations', () => {
withTestCodeEditor([
'hello',
'world'
], {}, (editor, cursor) => {
const model = editor.getModel();
], {}, (editor) => {
const model = editor.getModel()!;
const action = new DeleteAllRightAction();
editor.setSelection(new Selection(1, 2, 1, 5));
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['ho', 'world']);
assert.deepEqual(editor.getSelections(), [new Selection(1, 2, 1, 2)]);
editor.setSelection(new Selection(1, 1, 2, 4));
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['ld']);
assert.deepEqual(editor.getSelections(), [new Selection(1, 1, 1, 1)]);
editor.setSelection(new Selection(1, 1, 1, 3));
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['']);
assert.deepEqual(editor.getSelections(), [new Selection(1, 1, 1, 1)]);
});
@@ -646,17 +646,17 @@ suite('Editor Contrib - Line Operations', () => {
withTestCodeEditor([
'hello',
'world'
], {}, (editor, cursor) => {
const model = editor.getModel();
], {}, (editor) => {
const model = editor.getModel()!;
const action = new DeleteAllRightAction();
editor.setSelection(new Selection(1, 3, 1, 3));
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['he', 'world']);
assert.deepEqual(editor.getSelections(), [new Selection(1, 3, 1, 3)]);
editor.setSelection(new Selection(2, 1, 2, 1));
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['he', '']);
assert.deepEqual(editor.getSelections(), [new Selection(2, 1, 2, 1)]);
});
@@ -666,22 +666,22 @@ suite('Editor Contrib - Line Operations', () => {
withTestCodeEditor([
'hello',
'world'
], {}, (editor, cursor) => {
const model = editor.getModel();
], {}, (editor) => {
const model = editor.getModel()!;
const action = new DeleteAllRightAction();
editor.setSelection(new Selection(1, 6, 1, 6));
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['helloworld']);
assert.deepEqual(editor.getSelections(), [new Selection(1, 6, 1, 6)]);
editor.setSelection(new Selection(1, 6, 1, 6));
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['hello']);
assert.deepEqual(editor.getSelections(), [new Selection(1, 6, 1, 6)]);
editor.setSelection(new Selection(1, 6, 1, 6));
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['hello']);
assert.deepEqual(editor.getSelections(), [new Selection(1, 6, 1, 6)]);
});
@@ -692,8 +692,8 @@ suite('Editor Contrib - Line Operations', () => {
'hello',
'there',
'world'
], {}, (editor, cursor) => {
const model = editor.getModel();
], {}, (editor) => {
const model = editor.getModel()!;
const action = new DeleteAllRightAction();
editor.setSelections([
@@ -701,34 +701,34 @@ suite('Editor Contrib - Line Operations', () => {
new Selection(1, 6, 1, 6),
new Selection(3, 4, 3, 4),
]);
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['hethere', 'wor']);
assert.deepEqual(editor.getSelections(), [
new Selection(1, 3, 1, 3),
new Selection(2, 4, 2, 4)
]);
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['he', 'wor']);
assert.deepEqual(editor.getSelections(), [
new Selection(1, 3, 1, 3),
new Selection(2, 4, 2, 4)
]);
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['hewor']);
assert.deepEqual(editor.getSelections(), [
new Selection(1, 3, 1, 3),
new Selection(1, 6, 1, 6)
]);
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['he']);
assert.deepEqual(editor.getSelections(), [
new Selection(1, 3, 1, 3)
]);
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['he']);
assert.deepEqual(editor.getSelections(), [
new Selection(1, 3, 1, 3)
@@ -741,8 +741,8 @@ suite('Editor Contrib - Line Operations', () => {
'hello',
'there',
'world'
], {}, (editor, cursor) => {
const model = editor.getModel();
], {}, (editor) => {
const model = editor.getModel()!;
const action = new DeleteAllRightAction();
editor.setSelections([
@@ -750,7 +750,7 @@ suite('Editor Contrib - Line Operations', () => {
new Selection(1, 6, 1, 6),
new Selection(3, 4, 3, 4),
]);
action.run(null, editor);
action.run(null!, editor);
assert.deepEqual(model.getLinesContent(), ['hethere', 'wor']);
assert.deepEqual(editor.getSelections(), [
new Selection(1, 3, 1, 3),
@@ -783,8 +783,8 @@ suite('Editor Contrib - Line Operations', () => {
editor.setPosition(new Position(lineNumber, column));
let insertLineBeforeAction = new InsertLineBeforeAction();
insertLineBeforeAction.run(null, editor);
callback(editor.getModel(), cursor);
insertLineBeforeAction.run(null!, editor);
callback(editor.getModel()!, cursor);
});
}
@@ -824,8 +824,8 @@ suite('Editor Contrib - Line Operations', () => {
editor.setPosition(new Position(lineNumber, column));
let insertLineAfterAction = new InsertLineAfterAction();
insertLineAfterAction.run(null, editor);
callback(editor.getModel(), cursor);
insertLineAfterAction.run(null!, editor);
callback(editor.getModel()!, cursor);
});
}
@@ -865,11 +865,11 @@ suite('Editor Contrib - Line Operations', () => {
}
);
withTestCodeEditor(null, { model: model }, (editor, cursor) => {
withTestCodeEditor(null, { model: model }, (editor) => {
let indentLinesAction = new IndentLinesAction();
editor.setPosition(new Position(1, 2));
indentLinesAction.run(null, editor);
indentLinesAction.run(null!, editor);
assert.equal(model.getLineContent(1), '\tfunction baz() {');
assert.deepEqual(editor.getSelection(), new Selection(1, 3, 1, 3));
@@ -887,14 +887,14 @@ suite('Editor Contrib - Line Operations', () => {
'too',
'c',
];
withTestCodeEditor(TEXT, {}, (editor, cursor) => {
withTestCodeEditor(TEXT, {}, (editor) => {
editor.setSelections([
new Selection(2, 4, 2, 4),
new Selection(2, 8, 2, 8),
new Selection(3, 4, 3, 4),
]);
const deleteLinesAction = new DeleteLinesAction();
deleteLinesAction.run(null, editor);
deleteLinesAction.run(null!, editor);
assert.equal(editor.getValue(), 'a\nc');
});

View File

@@ -330,7 +330,7 @@ suite('Editor contrib - Move Lines Command honors Indentation Rules', () => {
test('move line should still work as before if there is no indentation rules', () => {
testMoveLinesUpWithIndentCommand(
null,
null!,
[
'if (true) {',
' var task = new Task(() => {',