mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Vscode merge (#4582)
* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd * fix issues with merges * bump node version in azpipe * replace license headers * remove duplicate launch task * fix build errors * fix build errors * fix tslint issues * working through package and linux build issues * more work * wip * fix packaged builds * working through linux build errors * wip * wip * wip * fix mac and linux file limits * iterate linux pipeline * disable editor typing * revert series to parallel * remove optimize vscode from linux * fix linting issues * revert testing change * add work round for new node * readd packaging for extensions * fix issue with angular not resolving decorator dependencies
This commit is contained in:
@@ -10,8 +10,8 @@ import { ITextModel } from 'vs/editor/common/model';
|
||||
|
||||
export class CopyLinesCommand implements editorCommon.ICommand {
|
||||
|
||||
private _selection: Selection;
|
||||
private _isCopyingDown: boolean;
|
||||
private readonly _selection: Selection;
|
||||
private readonly _isCopyingDown: boolean;
|
||||
|
||||
private _selectionDirection: SelectionDirection;
|
||||
private _selectionId: string;
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ICommand, ICursorStateComputerData, IEditOperationBuilder } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
|
||||
export class DeleteLinesCommand implements ICommand {
|
||||
|
||||
private startLineNumber: number;
|
||||
private endLineNumber: number;
|
||||
private restoreCursorToColumn: number;
|
||||
|
||||
constructor(startLineNumber: number, endLineNumber: number, restoreCursorToColumn: number) {
|
||||
this.startLineNumber = startLineNumber;
|
||||
this.endLineNumber = endLineNumber;
|
||||
this.restoreCursorToColumn = restoreCursorToColumn;
|
||||
}
|
||||
|
||||
public getEditOperations(model: ITextModel, builder: IEditOperationBuilder): void {
|
||||
if (model.getLineCount() === 1 && model.getLineMaxColumn(1) === 1) {
|
||||
// Model is empty
|
||||
return;
|
||||
}
|
||||
|
||||
let startLineNumber = this.startLineNumber;
|
||||
let endLineNumber = this.endLineNumber;
|
||||
|
||||
let startColumn = 1;
|
||||
let endColumn = model.getLineMaxColumn(endLineNumber);
|
||||
if (endLineNumber < model.getLineCount()) {
|
||||
endLineNumber += 1;
|
||||
endColumn = 1;
|
||||
} else if (startLineNumber > 1) {
|
||||
startLineNumber -= 1;
|
||||
startColumn = model.getLineMaxColumn(startLineNumber);
|
||||
}
|
||||
|
||||
builder.addTrackedEditOperation(new Range(startLineNumber, startColumn, endLineNumber, endColumn), null);
|
||||
}
|
||||
|
||||
public computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection {
|
||||
let inverseEditOperations = helper.getInverseEditOperations();
|
||||
let srcRange = inverseEditOperations[0].range;
|
||||
return new Selection(
|
||||
srcRange.endLineNumber,
|
||||
this.restoreCursorToColumn,
|
||||
srcRange.endLineNumber,
|
||||
this.restoreCursorToColumn
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as nls from 'vs/nls';
|
||||
import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { ICodeEditor, IActiveCodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction, IActionOptions, ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { ReplaceCommand, ReplaceCommandThatPreservesSelection } from 'vs/editor/common/commands/replaceCommand';
|
||||
import { TrimTrailingWhitespaceCommand } from 'vs/editor/common/commands/trimTrailingWhitespaceCommand';
|
||||
@@ -17,9 +17,8 @@ import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ICommand } from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
|
||||
import { IIdentifiedSingleEditOperation, ITextModel } from 'vs/editor/common/model';
|
||||
import { CopyLinesCommand } from 'vs/editor/contrib/linesOperations/copyLinesCommand';
|
||||
import { DeleteLinesCommand } from 'vs/editor/contrib/linesOperations/deleteLinesCommand';
|
||||
import { MoveLinesCommand } from 'vs/editor/contrib/linesOperations/moveLinesCommand';
|
||||
import { SortLinesCommand } from 'vs/editor/contrib/linesOperations/sortLinesCommand';
|
||||
import { MenuId } from 'vs/platform/actions/common/actions';
|
||||
@@ -29,7 +28,7 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
|
||||
|
||||
abstract class AbstractCopyLinesAction extends EditorAction {
|
||||
|
||||
private down: boolean;
|
||||
private readonly down: boolean;
|
||||
|
||||
constructor(down: boolean, opts: IActionOptions) {
|
||||
super(opts);
|
||||
@@ -101,7 +100,7 @@ class CopyLinesDownAction extends AbstractCopyLinesAction {
|
||||
|
||||
abstract class AbstractMoveLinesAction extends EditorAction {
|
||||
|
||||
private down: boolean;
|
||||
private readonly down: boolean;
|
||||
|
||||
constructor(down: boolean, opts: IActionOptions) {
|
||||
super(opts);
|
||||
@@ -171,7 +170,7 @@ class MoveLinesDownAction extends AbstractMoveLinesAction {
|
||||
}
|
||||
|
||||
export abstract class AbstractSortLinesAction extends EditorAction {
|
||||
private descending: boolean;
|
||||
private readonly descending: boolean;
|
||||
|
||||
constructor(descending: boolean, opts: IActionOptions) {
|
||||
super(opts);
|
||||
@@ -265,6 +264,7 @@ export class TrimTrailingWhitespaceAction extends EditorAction {
|
||||
|
||||
interface IDeleteLinesOperation {
|
||||
startLineNumber: number;
|
||||
selectionStartColumn: number;
|
||||
endLineNumber: number;
|
||||
positionColumn: number;
|
||||
}
|
||||
@@ -286,26 +286,50 @@ export class DeleteLinesAction extends EditorAction {
|
||||
}
|
||||
|
||||
public run(_accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
if (!editor.hasModel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let ops = this._getLinesToRemove(editor);
|
||||
|
||||
// Finally, construct the delete lines commands
|
||||
let commands: ICommand[] = ops.map((op) => {
|
||||
return new DeleteLinesCommand(op.startLineNumber, op.endLineNumber, op.positionColumn);
|
||||
});
|
||||
let model: ITextModel = editor.getModel();
|
||||
if (model.getLineCount() === 1 && model.getLineMaxColumn(1) === 1) {
|
||||
// Model is empty
|
||||
return;
|
||||
}
|
||||
|
||||
let linesDeleted = 0;
|
||||
let edits: IIdentifiedSingleEditOperation[] = [];
|
||||
let cursorState: Selection[] = [];
|
||||
for (let i = 0, len = ops.length; i < len; i++) {
|
||||
const op = ops[i];
|
||||
|
||||
let startLineNumber = op.startLineNumber;
|
||||
let endLineNumber = op.endLineNumber;
|
||||
|
||||
let startColumn = 1;
|
||||
let endColumn = model.getLineMaxColumn(endLineNumber);
|
||||
if (endLineNumber < model.getLineCount()) {
|
||||
endLineNumber += 1;
|
||||
endColumn = 1;
|
||||
} else if (startLineNumber > 1) {
|
||||
startLineNumber -= 1;
|
||||
startColumn = model.getLineMaxColumn(startLineNumber);
|
||||
}
|
||||
|
||||
edits.push(EditOperation.replace(new Selection(startLineNumber, startColumn, endLineNumber, endColumn), ''));
|
||||
cursorState.push(new Selection(startLineNumber - linesDeleted, op.positionColumn, startLineNumber - linesDeleted, op.positionColumn));
|
||||
linesDeleted += (op.endLineNumber - op.startLineNumber + 1);
|
||||
}
|
||||
|
||||
editor.pushUndoStop();
|
||||
editor.executeCommands(this.id, commands);
|
||||
editor.executeEdits(this.id, edits, cursorState);
|
||||
editor.pushUndoStop();
|
||||
}
|
||||
|
||||
private _getLinesToRemove(editor: ICodeEditor): IDeleteLinesOperation[] {
|
||||
private _getLinesToRemove(editor: IActiveCodeEditor): IDeleteLinesOperation[] {
|
||||
// Construct delete operations
|
||||
let selections = editor.getSelections();
|
||||
if (selections === null) {
|
||||
return [];
|
||||
}
|
||||
let operations: IDeleteLinesOperation[] = selections.map((s) => {
|
||||
let operations: IDeleteLinesOperation[] = editor.getSelections().map((s) => {
|
||||
|
||||
let endLineNumber = s.endLineNumber;
|
||||
if (s.startLineNumber < s.endLineNumber && s.endColumn === 1) {
|
||||
@@ -314,6 +338,7 @@ export class DeleteLinesAction extends EditorAction {
|
||||
|
||||
return {
|
||||
startLineNumber: s.startLineNumber,
|
||||
selectionStartColumn: s.selectionStartColumn,
|
||||
endLineNumber: endLineNumber,
|
||||
positionColumn: s.positionColumn
|
||||
};
|
||||
@@ -445,10 +470,10 @@ export class InsertLineAfterAction extends EditorAction {
|
||||
|
||||
export abstract class AbstractDeleteAllToBoundaryAction extends EditorAction {
|
||||
public run(_accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
const primaryCursor = editor.getSelection();
|
||||
if (primaryCursor === null) {
|
||||
if (!editor.hasModel()) {
|
||||
return;
|
||||
}
|
||||
const primaryCursor = editor.getSelection();
|
||||
|
||||
let rangesToDelete = this._getRangesToDelete(editor);
|
||||
// merge overlapping selections
|
||||
@@ -483,7 +508,7 @@ export abstract class AbstractDeleteAllToBoundaryAction extends EditorAction {
|
||||
*/
|
||||
protected abstract _getEndCursorState(primaryCursor: Range, rangesToDelete: Range[]): Selection[];
|
||||
|
||||
protected abstract _getRangesToDelete(editor: ICodeEditor): Range[];
|
||||
protected abstract _getRangesToDelete(editor: IActiveCodeEditor): Range[];
|
||||
}
|
||||
|
||||
export class DeleteAllLeftAction extends AbstractDeleteAllToBoundaryAction {
|
||||
@@ -532,7 +557,7 @@ export class DeleteAllLeftAction extends AbstractDeleteAllToBoundaryAction {
|
||||
return endCursorState;
|
||||
}
|
||||
|
||||
_getRangesToDelete(editor: ICodeEditor): Range[] {
|
||||
_getRangesToDelete(editor: IActiveCodeEditor): Range[] {
|
||||
let selections = editor.getSelections();
|
||||
if (selections === null) {
|
||||
return [];
|
||||
@@ -550,7 +575,7 @@ export class DeleteAllLeftAction extends AbstractDeleteAllToBoundaryAction {
|
||||
if (selection.isEmpty()) {
|
||||
if (selection.startColumn === 1) {
|
||||
let deleteFromLine = Math.max(1, selection.startLineNumber - 1);
|
||||
let deleteFromColumn = selection.startLineNumber === 1 ? 1 : model!.getLineContent(deleteFromLine).length + 1;
|
||||
let deleteFromColumn = selection.startLineNumber === 1 ? 1 : model.getLineContent(deleteFromLine).length + 1;
|
||||
return new Range(deleteFromLine, deleteFromColumn, selection.startLineNumber, 1);
|
||||
} else {
|
||||
return new Range(selection.startLineNumber, 1, selection.startLineNumber, selection.startColumn);
|
||||
@@ -601,7 +626,7 @@ export class DeleteAllRightAction extends AbstractDeleteAllToBoundaryAction {
|
||||
return endCursorState;
|
||||
}
|
||||
|
||||
_getRangesToDelete(editor: ICodeEditor): Range[] {
|
||||
_getRangesToDelete(editor: IActiveCodeEditor): Range[] {
|
||||
let model = editor.getModel();
|
||||
if (model === null) {
|
||||
return [];
|
||||
@@ -615,7 +640,7 @@ export class DeleteAllRightAction extends AbstractDeleteAllToBoundaryAction {
|
||||
|
||||
let rangesToDelete: Range[] = selections.map((sel) => {
|
||||
if (sel.isEmpty()) {
|
||||
const maxColumn = model!.getLineMaxColumn(sel.startLineNumber);
|
||||
const maxColumn = model.getLineMaxColumn(sel.startLineNumber);
|
||||
|
||||
if (sel.startColumn === maxColumn) {
|
||||
return new Range(sel.startLineNumber, sel.startColumn, sel.startLineNumber + 1, 1);
|
||||
|
||||
@@ -16,9 +16,9 @@ import * as indentUtils from 'vs/editor/contrib/indentation/indentUtils';
|
||||
|
||||
export class MoveLinesCommand implements ICommand {
|
||||
|
||||
private _selection: Selection;
|
||||
private _isMovingDown: boolean;
|
||||
private _autoIndent: boolean;
|
||||
private readonly _selection: Selection;
|
||||
private readonly _isMovingDown: boolean;
|
||||
private readonly _autoIndent: boolean;
|
||||
|
||||
private _selectionId: string;
|
||||
private _moveEndPositionDown: boolean;
|
||||
@@ -50,9 +50,8 @@ export class MoveLinesCommand implements ICommand {
|
||||
s = s.setEndPosition(s.endLineNumber - 1, model.getLineMaxColumn(s.endLineNumber - 1));
|
||||
}
|
||||
|
||||
let tabSize = model.getOptions().tabSize;
|
||||
let insertSpaces = model.getOptions().insertSpaces;
|
||||
let indentConverter = this.buildIndentConverter(tabSize);
|
||||
const { tabSize, indentSize, insertSpaces } = model.getOptions();
|
||||
let indentConverter = this.buildIndentConverter(tabSize, indentSize, insertSpaces);
|
||||
let virtualModel = {
|
||||
getLineTokens: (lineNumber: number) => {
|
||||
return model.getLineTokens(lineNumber);
|
||||
@@ -215,25 +214,13 @@ export class MoveLinesCommand implements ICommand {
|
||||
this._selectionId = builder.trackSelection(s);
|
||||
}
|
||||
|
||||
private buildIndentConverter(tabSize: number): IIndentConverter {
|
||||
private buildIndentConverter(tabSize: number, indentSize: number, insertSpaces: boolean): IIndentConverter {
|
||||
return {
|
||||
shiftIndent: (indentation) => {
|
||||
let desiredIndentCount = ShiftCommand.shiftIndentCount(indentation, indentation.length + 1, tabSize);
|
||||
let newIndentation = '';
|
||||
for (let i = 0; i < desiredIndentCount; i++) {
|
||||
newIndentation += '\t';
|
||||
}
|
||||
|
||||
return newIndentation;
|
||||
return ShiftCommand.shiftIndent(indentation, indentation.length + 1, tabSize, indentSize, insertSpaces);
|
||||
},
|
||||
unshiftIndent: (indentation) => {
|
||||
let desiredIndentCount = ShiftCommand.unshiftIndentCount(indentation, indentation.length + 1, tabSize);
|
||||
let newIndentation = '';
|
||||
for (let i = 0; i < desiredIndentCount; i++) {
|
||||
newIndentation += '\t';
|
||||
}
|
||||
|
||||
return newIndentation;
|
||||
return ShiftCommand.unshiftIndent(indentation, indentation.length + 1, tabSize, indentSize, insertSpaces);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ import { IIdentifiedSingleEditOperation, ITextModel } from 'vs/editor/common/mod
|
||||
|
||||
export class SortLinesCommand implements editorCommon.ICommand {
|
||||
|
||||
private selection: Selection;
|
||||
private readonly selection: Selection;
|
||||
private selectionId: string;
|
||||
private descending: boolean;
|
||||
private readonly descending: boolean;
|
||||
|
||||
constructor(selection: Selection, descending: boolean) {
|
||||
this.selection = selection;
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { DeleteLinesCommand } from 'vs/editor/contrib/linesOperations/deleteLinesCommand';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
|
||||
function createFromSelection(selection: Selection): DeleteLinesCommand {
|
||||
let endLineNumber = selection.endLineNumber;
|
||||
if (selection.startLineNumber < selection.endLineNumber && selection.endColumn === 1) {
|
||||
endLineNumber -= 1;
|
||||
}
|
||||
return new DeleteLinesCommand(selection.startLineNumber, endLineNumber, selection.positionColumn);
|
||||
}
|
||||
|
||||
function testDeleteLinesCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
|
||||
testCommand(lines, null, selection, (sel) => createFromSelection(sel), expectedLines, expectedSelection);
|
||||
}
|
||||
|
||||
suite('Editor Contrib - Delete Lines Command', () => {
|
||||
|
||||
test('empty selection in middle of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 3, 2, 3),
|
||||
[
|
||||
'first',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 3, 2, 3)
|
||||
);
|
||||
});
|
||||
|
||||
test('empty selection at top of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5),
|
||||
[
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('empty selection at end of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(5, 2, 5, 2),
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line'
|
||||
],
|
||||
new Selection(4, 2, 4, 2)
|
||||
);
|
||||
});
|
||||
|
||||
test('with selection in middle of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(3, 3, 2, 2),
|
||||
[
|
||||
'first',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 2, 2, 2)
|
||||
);
|
||||
});
|
||||
|
||||
test('with selection at top of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 4, 1, 5),
|
||||
[
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('with selection at end of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(5, 1, 5, 2),
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line'
|
||||
],
|
||||
new Selection(4, 2, 4, 2)
|
||||
);
|
||||
});
|
||||
|
||||
test('with full line selection in middle of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(4, 1, 2, 1),
|
||||
[
|
||||
'first',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 1, 2, 1)
|
||||
);
|
||||
});
|
||||
|
||||
test('with full line selection at top of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 1, 1, 5),
|
||||
[
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('with full line selection at end of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(4, 1, 5, 2),
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line'
|
||||
],
|
||||
new Selection(3, 2, 3, 2)
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -899,4 +899,250 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
assert.equal(editor.getValue(), 'a\nc');
|
||||
});
|
||||
});
|
||||
|
||||
function testDeleteLinesCommand(initialText: string[], _initialSelections: Selection | Selection[], resultingText: string[], _resultingSelections: Selection | Selection[]): void {
|
||||
const initialSelections = Array.isArray(_initialSelections) ? _initialSelections : [_initialSelections];
|
||||
const resultingSelections = Array.isArray(_resultingSelections) ? _resultingSelections : [_resultingSelections];
|
||||
withTestCodeEditor(initialText, {}, (editor) => {
|
||||
editor.setSelections(initialSelections);
|
||||
const deleteLinesAction = new DeleteLinesAction();
|
||||
deleteLinesAction.run(null!, editor);
|
||||
|
||||
assert.equal(editor.getValue(), resultingText.join('\n'));
|
||||
assert.deepEqual(editor.getSelections(), resultingSelections);
|
||||
});
|
||||
}
|
||||
|
||||
test('empty selection in middle of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 3, 2, 3),
|
||||
[
|
||||
'first',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 3, 2, 3)
|
||||
);
|
||||
});
|
||||
|
||||
test('empty selection at top of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5),
|
||||
[
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('empty selection at end of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(5, 2, 5, 2),
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line'
|
||||
],
|
||||
new Selection(4, 2, 4, 2)
|
||||
);
|
||||
});
|
||||
|
||||
test('with selection in middle of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(3, 3, 2, 2),
|
||||
[
|
||||
'first',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 2, 2, 2)
|
||||
);
|
||||
});
|
||||
|
||||
test('with selection at top of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 4, 1, 5),
|
||||
[
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('with selection at end of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(5, 1, 5, 2),
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line'
|
||||
],
|
||||
new Selection(4, 2, 4, 2)
|
||||
);
|
||||
});
|
||||
|
||||
test('with full line selection in middle of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(4, 1, 2, 1),
|
||||
[
|
||||
'first',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 1, 2, 1)
|
||||
);
|
||||
});
|
||||
|
||||
test('with full line selection at top of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 1, 1, 5),
|
||||
[
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('with full line selection at end of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(4, 1, 5, 2),
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line'
|
||||
],
|
||||
new Selection(3, 2, 3, 2)
|
||||
);
|
||||
});
|
||||
|
||||
test('multicursor 1', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'class P {',
|
||||
'',
|
||||
' getA() {',
|
||||
' if (true) {',
|
||||
' return "a";',
|
||||
' }',
|
||||
' }',
|
||||
'',
|
||||
' getB() {',
|
||||
' if (true) {',
|
||||
' return "b";',
|
||||
' }',
|
||||
' }',
|
||||
'',
|
||||
' getC() {',
|
||||
' if (true) {',
|
||||
' return "c";',
|
||||
' }',
|
||||
' }',
|
||||
'}',
|
||||
],
|
||||
[
|
||||
new Selection(4, 1, 5, 1),
|
||||
new Selection(10, 1, 11, 1),
|
||||
new Selection(16, 1, 17, 1),
|
||||
],
|
||||
[
|
||||
'class P {',
|
||||
'',
|
||||
' getA() {',
|
||||
' return "a";',
|
||||
' }',
|
||||
' }',
|
||||
'',
|
||||
' getB() {',
|
||||
' return "b";',
|
||||
' }',
|
||||
' }',
|
||||
'',
|
||||
' getC() {',
|
||||
' return "c";',
|
||||
' }',
|
||||
' }',
|
||||
'}',
|
||||
],
|
||||
[
|
||||
new Selection(4, 1, 4, 1),
|
||||
new Selection(9, 1, 9, 1),
|
||||
new Selection(14, 1, 14, 1),
|
||||
]
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user