mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -8,17 +8,8 @@ import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ICommand, ICursorStateComputerData, IEditOperationBuilder, ITokenizedModel } from 'vs/editor/common/editorCommon';
|
||||
|
||||
|
||||
export class DeleteLinesCommand implements ICommand {
|
||||
|
||||
public static createFromSelection(selection: Selection): DeleteLinesCommand {
|
||||
var endLineNumber = selection.endLineNumber;
|
||||
if (selection.startLineNumber < selection.endLineNumber && selection.endColumn === 1) {
|
||||
endLineNumber -= 1;
|
||||
}
|
||||
return new DeleteLinesCommand(selection.startLineNumber, endLineNumber, selection.positionColumn);
|
||||
}
|
||||
|
||||
private startLineNumber: number;
|
||||
private endLineNumber: number;
|
||||
private restoreCursorToColumn: number;
|
||||
@@ -6,21 +6,22 @@
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { KeyCode, KeyMod, KeyChord } from 'vs/base/common/keyCodes';
|
||||
import { SortLinesCommand } from 'vs/editor/contrib/linesOperations/common/sortLinesCommand';
|
||||
import { SortLinesCommand } from 'vs/editor/contrib/linesOperations/sortLinesCommand';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { TrimTrailingWhitespaceCommand } from 'vs/editor/common/commands/trimTrailingWhitespaceCommand';
|
||||
import { ICommand, ICommonCodeEditor, IIdentifiedSingleEditOperation } from 'vs/editor/common/editorCommon';
|
||||
import { ICommand, IIdentifiedSingleEditOperation } from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { ReplaceCommand, ReplaceCommandThatPreservesSelection } from 'vs/editor/common/commands/replaceCommand';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { editorAction, ServicesAccessor, IActionOptions, EditorAction } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { registerEditorAction, ServicesAccessor, IActionOptions, EditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { CopyLinesCommand } from './copyLinesCommand';
|
||||
import { DeleteLinesCommand } from './deleteLinesCommand';
|
||||
import { MoveLinesCommand } from './moveLinesCommand';
|
||||
import { TypeOperations } from 'vs/editor/common/controller/cursorTypeOperations';
|
||||
import { CoreEditingCommands } from 'vs/editor/common/controller/coreCommands';
|
||||
import { CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
||||
// copy lines
|
||||
|
||||
@@ -33,7 +34,7 @@ abstract class AbstractCopyLinesAction extends EditorAction {
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
|
||||
var commands: ICommand[] = [];
|
||||
var selections = editor.getSelections();
|
||||
@@ -48,7 +49,6 @@ abstract class AbstractCopyLinesAction extends EditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
class CopyLinesUpAction extends AbstractCopyLinesAction {
|
||||
constructor() {
|
||||
super(false, {
|
||||
@@ -65,7 +65,6 @@ class CopyLinesUpAction extends AbstractCopyLinesAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
class CopyLinesDownAction extends AbstractCopyLinesAction {
|
||||
constructor() {
|
||||
super(true, {
|
||||
@@ -93,7 +92,7 @@ abstract class AbstractMoveLinesAction extends EditorAction {
|
||||
this.down = down;
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
|
||||
var commands: ICommand[] = [];
|
||||
var selections = editor.getSelections();
|
||||
@@ -109,7 +108,6 @@ abstract class AbstractMoveLinesAction extends EditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
class MoveLinesUpAction extends AbstractMoveLinesAction {
|
||||
constructor() {
|
||||
super(false, {
|
||||
@@ -126,7 +124,6 @@ class MoveLinesUpAction extends AbstractMoveLinesAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
class MoveLinesDownAction extends AbstractMoveLinesAction {
|
||||
constructor() {
|
||||
super(true, {
|
||||
@@ -143,7 +140,7 @@ class MoveLinesDownAction extends AbstractMoveLinesAction {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractSortLinesAction extends EditorAction {
|
||||
export abstract class AbstractSortLinesAction extends EditorAction {
|
||||
private descending: boolean;
|
||||
|
||||
constructor(descending: boolean, opts: IActionOptions) {
|
||||
@@ -151,22 +148,28 @@ abstract class AbstractSortLinesAction extends EditorAction {
|
||||
this.descending = descending;
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
const selections = editor.getSelections();
|
||||
|
||||
if (!SortLinesCommand.canRun(editor.getModel(), editor.getSelection(), this.descending)) {
|
||||
return;
|
||||
for (let i = 0, len = selections.length; i < len; i++) {
|
||||
const selection = selections[i];
|
||||
if (!SortLinesCommand.canRun(editor.getModel(), selection, this.descending)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var command = new SortLinesCommand(editor.getSelection(), this.descending);
|
||||
let commands: ICommand[] = [];
|
||||
for (let i = 0, len = selections.length; i < len; i++) {
|
||||
commands[i] = new SortLinesCommand(selections[i], this.descending);
|
||||
}
|
||||
|
||||
editor.pushUndoStop();
|
||||
editor.executeCommands(this.id, [command]);
|
||||
editor.executeCommands(this.id, commands);
|
||||
editor.pushUndoStop();
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
class SortLinesAscendingAction extends AbstractSortLinesAction {
|
||||
export class SortLinesAscendingAction extends AbstractSortLinesAction {
|
||||
constructor() {
|
||||
super(false, {
|
||||
id: 'editor.action.sortLinesAscending',
|
||||
@@ -177,8 +180,7 @@ class SortLinesAscendingAction extends AbstractSortLinesAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
class SortLinesDescendingAction extends AbstractSortLinesAction {
|
||||
export class SortLinesDescendingAction extends AbstractSortLinesAction {
|
||||
constructor() {
|
||||
super(true, {
|
||||
id: 'editor.action.sortLinesDescending',
|
||||
@@ -189,10 +191,9 @@ class SortLinesDescendingAction extends AbstractSortLinesAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class TrimTrailingWhitespaceAction extends EditorAction {
|
||||
|
||||
public static ID = 'editor.action.trimTrailingWhitespace';
|
||||
public static readonly ID = 'editor.action.trimTrailingWhitespace';
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
@@ -207,7 +208,7 @@ export class TrimTrailingWhitespaceAction extends EditorAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor, args: any): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor, args: any): void {
|
||||
|
||||
let cursors: Position[] = [];
|
||||
if (args.reason === 'auto-save') {
|
||||
@@ -234,7 +235,7 @@ interface IDeleteLinesOperation {
|
||||
}
|
||||
|
||||
abstract class AbstractRemoveLinesAction extends EditorAction {
|
||||
_getLinesToRemove(editor: ICommonCodeEditor): IDeleteLinesOperation[] {
|
||||
_getLinesToRemove(editor: ICodeEditor): IDeleteLinesOperation[] {
|
||||
// Construct delete operations
|
||||
var operations: IDeleteLinesOperation[] = editor.getSelections().map((s) => {
|
||||
|
||||
@@ -275,7 +276,6 @@ abstract class AbstractRemoveLinesAction extends EditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
class DeleteLinesAction extends AbstractRemoveLinesAction {
|
||||
|
||||
constructor() {
|
||||
@@ -291,7 +291,7 @@ class DeleteLinesAction extends AbstractRemoveLinesAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
|
||||
var ops = this._getLinesToRemove(editor);
|
||||
|
||||
@@ -306,7 +306,6 @@ class DeleteLinesAction extends AbstractRemoveLinesAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class IndentLinesAction extends EditorAction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -321,14 +320,13 @@ export class IndentLinesAction extends EditorAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
editor.pushUndoStop();
|
||||
editor.executeCommands(this.id, TypeOperations.indent(editor._getCursorConfiguration(), editor.getModel(), editor.getSelections()));
|
||||
editor.pushUndoStop();
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
class OutdentLinesAction extends EditorAction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -343,12 +341,11 @@ class OutdentLinesAction extends EditorAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
CoreEditingCommands.Outdent.runEditorCommand(null, editor, null);
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class InsertLineBeforeAction extends EditorAction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -363,13 +360,12 @@ export class InsertLineBeforeAction extends EditorAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
editor.pushUndoStop();
|
||||
editor.executeCommands(this.id, TypeOperations.lineInsertBefore(editor._getCursorConfiguration(), editor.getModel(), editor.getSelections()));
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class InsertLineAfterAction extends EditorAction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -384,14 +380,14 @@ export class InsertLineAfterAction extends EditorAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
editor.pushUndoStop();
|
||||
editor.executeCommands(this.id, TypeOperations.lineInsertAfter(editor._getCursorConfiguration(), editor.getModel(), editor.getSelections()));
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class AbstractDeleteAllToBoundaryAction extends EditorAction {
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
const primaryCursor = editor.getSelection();
|
||||
let rangesToDelete = this._getRangesToDelete(editor);
|
||||
// merge overlapping selections
|
||||
@@ -426,10 +422,9 @@ export abstract class AbstractDeleteAllToBoundaryAction extends EditorAction {
|
||||
*/
|
||||
protected abstract _getEndCursorState(primaryCursor: Range, rangesToDelete: Range[]): Selection[];
|
||||
|
||||
protected abstract _getRangesToDelete(editor: ICommonCodeEditor): Range[];
|
||||
protected abstract _getRangesToDelete(editor: ICodeEditor): Range[];
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class DeleteAllLeftAction extends AbstractDeleteAllToBoundaryAction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -467,7 +462,7 @@ export class DeleteAllLeftAction extends AbstractDeleteAllToBoundaryAction {
|
||||
return endCursorState;
|
||||
}
|
||||
|
||||
_getRangesToDelete(editor: ICommonCodeEditor): Range[] {
|
||||
_getRangesToDelete(editor: ICodeEditor): Range[] {
|
||||
let rangesToDelete: Range[] = editor.getSelections();
|
||||
|
||||
rangesToDelete.sort(Range.compareRangesUsingStarts);
|
||||
@@ -483,7 +478,6 @@ export class DeleteAllLeftAction extends AbstractDeleteAllToBoundaryAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class DeleteAllRightAction extends AbstractDeleteAllToBoundaryAction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -520,7 +514,7 @@ export class DeleteAllRightAction extends AbstractDeleteAllToBoundaryAction {
|
||||
return endCursorState;
|
||||
}
|
||||
|
||||
_getRangesToDelete(editor: ICommonCodeEditor): Range[] {
|
||||
_getRangesToDelete(editor: ICodeEditor): Range[] {
|
||||
let model = editor.getModel();
|
||||
|
||||
let rangesToDelete: Range[] = editor.getSelections().map((sel) => {
|
||||
@@ -541,7 +535,6 @@ export class DeleteAllRightAction extends AbstractDeleteAllToBoundaryAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class JoinLinesAction extends EditorAction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -557,7 +550,7 @@ export class JoinLinesAction extends EditorAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
let selections = editor.getSelections();
|
||||
let primaryCursor = editor.getSelection();
|
||||
|
||||
@@ -690,7 +683,6 @@ export class JoinLinesAction extends EditorAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class TransposeAction extends EditorAction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -701,7 +693,7 @@ export class TransposeAction extends EditorAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
let selections = editor.getSelections();
|
||||
let model = editor.getModel();
|
||||
let commands: ICommand[] = [];
|
||||
@@ -742,7 +734,7 @@ export class TransposeAction extends EditorAction {
|
||||
}
|
||||
|
||||
export abstract class AbstractCaseAction extends EditorAction {
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
let selections = editor.getSelections();
|
||||
let model = editor.getModel();
|
||||
let commands: ICommand[] = [];
|
||||
@@ -776,7 +768,6 @@ export abstract class AbstractCaseAction extends EditorAction {
|
||||
protected abstract _modifyText(text: string): string;
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class UpperCaseAction extends AbstractCaseAction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -792,7 +783,6 @@ export class UpperCaseAction extends AbstractCaseAction {
|
||||
}
|
||||
}
|
||||
|
||||
@editorAction
|
||||
export class LowerCaseAction extends AbstractCaseAction {
|
||||
constructor() {
|
||||
super({
|
||||
@@ -807,3 +797,22 @@ export class LowerCaseAction extends AbstractCaseAction {
|
||||
return text.toLocaleLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
registerEditorAction(CopyLinesUpAction);
|
||||
registerEditorAction(CopyLinesDownAction);
|
||||
registerEditorAction(MoveLinesUpAction);
|
||||
registerEditorAction(MoveLinesDownAction);
|
||||
registerEditorAction(SortLinesAscendingAction);
|
||||
registerEditorAction(SortLinesDescendingAction);
|
||||
registerEditorAction(TrimTrailingWhitespaceAction);
|
||||
registerEditorAction(DeleteLinesAction);
|
||||
registerEditorAction(IndentLinesAction);
|
||||
registerEditorAction(OutdentLinesAction);
|
||||
registerEditorAction(InsertLineBeforeAction);
|
||||
registerEditorAction(InsertLineAfterAction);
|
||||
registerEditorAction(DeleteAllLeftAction);
|
||||
registerEditorAction(DeleteAllRightAction);
|
||||
registerEditorAction(JoinLinesAction);
|
||||
registerEditorAction(TransposeAction);
|
||||
registerEditorAction(UpperCaseAction);
|
||||
registerEditorAction(LowerCaseAction);
|
||||
@@ -10,7 +10,7 @@ import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { ICommand, ICursorStateComputerData, IEditOperationBuilder, ITokenizedModel } from 'vs/editor/common/editorCommon';
|
||||
import { LanguageConfigurationRegistry, IIndentConverter } from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import { ShiftCommand } from 'vs/editor/common/commands/shiftCommand';
|
||||
import * as IndentUtil from 'vs/editor/contrib/indentation/common/indentUtils';
|
||||
import * as IndentUtil from 'vs/editor/contrib/indentation/indentUtils';
|
||||
import { IndentAction } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import { IndentConsts } from 'vs/editor/common/modes/supports/indentRules';
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
'use strict';
|
||||
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { CopyLinesCommand } from 'vs/editor/contrib/linesOperations/common/copyLinesCommand';
|
||||
import { testCommand } from 'vs/editor/test/common/commands/commandTestUtils';
|
||||
import { CopyLinesCommand } from 'vs/editor/contrib/linesOperations/copyLinesCommand';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
|
||||
function testCopyLinesDownCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
|
||||
testCommand(lines, null, selection, (sel) => new CopyLinesCommand(sel, true), expectedLines, expectedSelection);
|
||||
@@ -196,5 +196,3 @@ suite('Editor Contrib - Copy Lines Command', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -5,11 +5,19 @@
|
||||
'use strict';
|
||||
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { DeleteLinesCommand } from 'vs/editor/contrib/linesOperations/common/deleteLinesCommand';
|
||||
import { testCommand } from 'vs/editor/test/common/commands/commandTestUtils';
|
||||
import { DeleteLinesCommand } from 'vs/editor/contrib/linesOperations/deleteLinesCommand';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
|
||||
function createFromSelection(selection: Selection): DeleteLinesCommand {
|
||||
var 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) => DeleteLinesCommand.createFromSelection(sel), expectedLines, expectedSelection);
|
||||
testCommand(lines, null, selection, (sel) => createFromSelection(sel), expectedLines, expectedSelection);
|
||||
}
|
||||
|
||||
suite('Editor Contrib - Delete Lines Command', () => {
|
||||
@@ -191,4 +199,3 @@ suite('Editor Contrib - Delete Lines Command', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,16 +8,133 @@ import * as assert from 'assert';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Handler, IModel, DefaultEndOfLine } from 'vs/editor/common/editorCommon';
|
||||
import { withMockCodeEditor } from 'vs/editor/test/common/mocks/mockCodeEditor';
|
||||
import { DeleteAllLeftAction, JoinLinesAction, TransposeAction, UpperCaseAction, LowerCaseAction, DeleteAllRightAction, InsertLineBeforeAction, InsertLineAfterAction, IndentLinesAction } from 'vs/editor/contrib/linesOperations/common/linesOperations';
|
||||
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import { DeleteAllLeftAction, JoinLinesAction, TransposeAction, UpperCaseAction, LowerCaseAction, DeleteAllRightAction, InsertLineBeforeAction, InsertLineAfterAction, IndentLinesAction, SortLinesAscendingAction, SortLinesDescendingAction } from 'vs/editor/contrib/linesOperations/linesOperations';
|
||||
import { Cursor } from 'vs/editor/common/controller/cursor';
|
||||
import { Model } from 'vs/editor/common/model/model';
|
||||
import { CoreEditingCommands } from 'vs/editor/common/controller/coreCommands';
|
||||
import { CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands';
|
||||
|
||||
suite('Editor Contrib - Line Operations', () => {
|
||||
suite('SortLinesAscendingAction', () => {
|
||||
test('should sort selected lines in ascending order', function () {
|
||||
withTestCodeEditor(
|
||||
[
|
||||
'omicron',
|
||||
'beta',
|
||||
'alpha'
|
||||
], {}, (editor, cursor) => {
|
||||
let model = editor.getModel();
|
||||
let sortLinesAscendingAction = new SortLinesAscendingAction();
|
||||
|
||||
editor.setSelection(new Selection(1, 1, 3, 5));
|
||||
sortLinesAscendingAction.run(null, editor);
|
||||
assert.deepEqual(model.getLinesContent(), [
|
||||
'alpha',
|
||||
'beta',
|
||||
'omicron'
|
||||
]);
|
||||
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 3, 7).toString());
|
||||
});
|
||||
});
|
||||
|
||||
test('should sort multiple selections in ascending order', function () {
|
||||
withTestCodeEditor(
|
||||
[
|
||||
'omicron',
|
||||
'beta',
|
||||
'alpha',
|
||||
'',
|
||||
'omicron',
|
||||
'beta',
|
||||
'alpha'
|
||||
], {}, (editor, cursor) => {
|
||||
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);
|
||||
assert.deepEqual(model.getLinesContent(), [
|
||||
'alpha',
|
||||
'beta',
|
||||
'omicron',
|
||||
'',
|
||||
'alpha',
|
||||
'beta',
|
||||
'omicron'
|
||||
]);
|
||||
let expectedSelections = [
|
||||
new Selection(1, 1, 3, 7),
|
||||
new Selection(5, 1, 7, 7)
|
||||
];
|
||||
editor.getSelections().forEach((actualSelection, index) => {
|
||||
assert.deepEqual(actualSelection.toString(), expectedSelections[index].toString());
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('SortLinesDescendingAction', () => {
|
||||
test('should sort selected lines in descending order', function () {
|
||||
withTestCodeEditor(
|
||||
[
|
||||
'alpha',
|
||||
'beta',
|
||||
'omicron'
|
||||
], {}, (editor, cursor) => {
|
||||
let model = editor.getModel();
|
||||
let sortLinesDescendingAction = new SortLinesDescendingAction();
|
||||
|
||||
editor.setSelection(new Selection(1, 1, 3, 7));
|
||||
sortLinesDescendingAction.run(null, editor);
|
||||
assert.deepEqual(model.getLinesContent(), [
|
||||
'omicron',
|
||||
'beta',
|
||||
'alpha'
|
||||
]);
|
||||
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 3, 5).toString());
|
||||
});
|
||||
});
|
||||
|
||||
test('should sort multiple selections in descending order', function () {
|
||||
withTestCodeEditor(
|
||||
[
|
||||
'alpha',
|
||||
'beta',
|
||||
'omicron',
|
||||
'',
|
||||
'alpha',
|
||||
'beta',
|
||||
'omicron'
|
||||
], {}, (editor, cursor) => {
|
||||
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);
|
||||
assert.deepEqual(model.getLinesContent(), [
|
||||
'omicron',
|
||||
'beta',
|
||||
'alpha',
|
||||
'',
|
||||
'omicron',
|
||||
'beta',
|
||||
'alpha'
|
||||
]);
|
||||
let expectedSelections = [
|
||||
new Selection(1, 1, 3, 5),
|
||||
new Selection(5, 1, 7, 5)
|
||||
];
|
||||
editor.getSelections().forEach((actualSelection, index) => {
|
||||
assert.deepEqual(actualSelection.toString(), expectedSelections[index].toString());
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
suite('DeleteAllLeftAction', () => {
|
||||
test('should delete to the left of the cursor', function () {
|
||||
withMockCodeEditor(
|
||||
withTestCodeEditor(
|
||||
[
|
||||
'one',
|
||||
'two',
|
||||
@@ -38,7 +155,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
});
|
||||
|
||||
test('should work in multi cursor mode', function () {
|
||||
withMockCodeEditor(
|
||||
withTestCodeEditor(
|
||||
[
|
||||
'hello',
|
||||
'world',
|
||||
@@ -75,7 +192,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
});
|
||||
|
||||
test('issue #36234: should push undo stop', () => {
|
||||
withMockCodeEditor(
|
||||
withTestCodeEditor(
|
||||
[
|
||||
'one',
|
||||
'two',
|
||||
@@ -103,7 +220,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
|
||||
suite('JoinLinesAction', () => {
|
||||
test('should join lines and insert space if necessary', function () {
|
||||
withMockCodeEditor(
|
||||
withTestCodeEditor(
|
||||
[
|
||||
'hello',
|
||||
'world',
|
||||
@@ -148,7 +265,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
});
|
||||
|
||||
test('should work in multi cursor mode', function () {
|
||||
withMockCodeEditor(
|
||||
withTestCodeEditor(
|
||||
[
|
||||
'hello',
|
||||
'world',
|
||||
@@ -192,7 +309,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
});
|
||||
|
||||
test('should push undo stop', function () {
|
||||
withMockCodeEditor(
|
||||
withTestCodeEditor(
|
||||
[
|
||||
'hello',
|
||||
'world'
|
||||
@@ -218,7 +335,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
});
|
||||
|
||||
test('transpose', function () {
|
||||
withMockCodeEditor(
|
||||
withTestCodeEditor(
|
||||
[
|
||||
'hello world',
|
||||
'',
|
||||
@@ -256,7 +373,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
);
|
||||
|
||||
// fix #16633
|
||||
withMockCodeEditor(
|
||||
withTestCodeEditor(
|
||||
[
|
||||
'',
|
||||
'',
|
||||
@@ -294,7 +411,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
});
|
||||
|
||||
test('toggle case', function () {
|
||||
withMockCodeEditor(
|
||||
withTestCodeEditor(
|
||||
[
|
||||
'hello world',
|
||||
'öçşğü'
|
||||
@@ -335,7 +452,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
}
|
||||
);
|
||||
|
||||
withMockCodeEditor(
|
||||
withTestCodeEditor(
|
||||
[
|
||||
'',
|
||||
' '
|
||||
@@ -369,7 +486,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
|
||||
suite('DeleteAllRightAction', () => {
|
||||
test('should be noop on empty', () => {
|
||||
withMockCodeEditor([''], {}, (editor, cursor) => {
|
||||
withTestCodeEditor([''], {}, (editor, cursor) => {
|
||||
const model = editor.getModel();
|
||||
const action = new DeleteAllRightAction();
|
||||
|
||||
@@ -390,7 +507,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
});
|
||||
|
||||
test('should delete selected range', () => {
|
||||
withMockCodeEditor([
|
||||
withTestCodeEditor([
|
||||
'hello',
|
||||
'world'
|
||||
], {}, (editor, cursor) => {
|
||||
@@ -415,7 +532,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
});
|
||||
|
||||
test('should delete to the right of the cursor', () => {
|
||||
withMockCodeEditor([
|
||||
withTestCodeEditor([
|
||||
'hello',
|
||||
'world'
|
||||
], {}, (editor, cursor) => {
|
||||
@@ -435,7 +552,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
});
|
||||
|
||||
test('should join two lines, if at the end of the line', () => {
|
||||
withMockCodeEditor([
|
||||
withTestCodeEditor([
|
||||
'hello',
|
||||
'world'
|
||||
], {}, (editor, cursor) => {
|
||||
@@ -460,7 +577,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
});
|
||||
|
||||
test('should work with multiple cursors', () => {
|
||||
withMockCodeEditor([
|
||||
withTestCodeEditor([
|
||||
'hello',
|
||||
'there',
|
||||
'world'
|
||||
@@ -509,7 +626,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
});
|
||||
|
||||
test('should work with undo/redo', () => {
|
||||
withMockCodeEditor([
|
||||
withTestCodeEditor([
|
||||
'hello',
|
||||
'there',
|
||||
'world'
|
||||
@@ -551,7 +668,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
'Second line',
|
||||
'Third line'
|
||||
];
|
||||
withMockCodeEditor(TEXT, {}, (editor, cursor) => {
|
||||
withTestCodeEditor(TEXT, {}, (editor, cursor) => {
|
||||
editor.setPosition(new Position(lineNumber, column));
|
||||
let insertLineBeforeAction = new InsertLineBeforeAction();
|
||||
|
||||
@@ -592,7 +709,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
'Second line',
|
||||
'Third line'
|
||||
];
|
||||
withMockCodeEditor(TEXT, {}, (editor, cursor) => {
|
||||
withTestCodeEditor(TEXT, {}, (editor, cursor) => {
|
||||
editor.setPosition(new Position(lineNumber, column));
|
||||
let insertLineAfterAction = new InsertLineAfterAction();
|
||||
|
||||
@@ -641,7 +758,7 @@ suite('Editor Contrib - Line Operations', () => {
|
||||
}
|
||||
);
|
||||
|
||||
withMockCodeEditor(null, { model: model }, (editor, cursor) => {
|
||||
withTestCodeEditor(null, { model: model }, (editor, cursor) => {
|
||||
let indentLinesAction = new IndentLinesAction();
|
||||
editor.setPosition(new Position(1, 2));
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { MoveLinesCommand } from 'vs/editor/contrib/linesOperations/common/moveLinesCommand';
|
||||
import { testCommand } from 'vs/editor/test/common/commands/commandTestUtils';
|
||||
import { MoveLinesCommand } from 'vs/editor/contrib/linesOperations/moveLinesCommand';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
import { MockMode } from 'vs/editor/test/common/mocks/mockMode';
|
||||
import { LanguageIdentifier } from 'vs/editor/common/modes';
|
||||
import { IndentationRule } from 'vs/editor/common/modes/languageConfiguration';
|
||||
@@ -260,7 +260,7 @@ suite('Editor Contrib - Move Lines Command', () => {
|
||||
});
|
||||
|
||||
class IndentRulesMode extends MockMode {
|
||||
private static _id = new LanguageIdentifier('moveLinesIndentMode', 7);
|
||||
private static readonly _id = new LanguageIdentifier('moveLinesIndentMode', 7);
|
||||
constructor(indentationRules: IndentationRule) {
|
||||
super(IndentRulesMode._id);
|
||||
this._register(LanguageConfigurationRegistry.register(this.getLanguageIdentifier(), {
|
||||
@@ -350,4 +350,4 @@ suite('Editor contrib - Move Lines Command honors Indentation Rules', () => {
|
||||
new Selection(2, 1, 2, 1)
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -5,8 +5,8 @@
|
||||
'use strict';
|
||||
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { SortLinesCommand } from 'vs/editor/contrib/linesOperations/common/sortLinesCommand';
|
||||
import { testCommand } from 'vs/editor/test/common/commands/commandTestUtils';
|
||||
import { SortLinesCommand } from 'vs/editor/contrib/linesOperations/sortLinesCommand';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
|
||||
function testSortLinesAscendingCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
|
||||
testCommand(lines, null, selection, (sel) => new SortLinesCommand(sel, false), expectedLines, expectedSelection);
|
||||
@@ -123,7 +123,7 @@ suite('Editor Contrib - Sort Lines Command', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('sorting first 4 lines desscending', function () {
|
||||
test('sorting first 4 lines descending', function () {
|
||||
testSortLinesDescendingCommand(
|
||||
[
|
||||
'first',
|
||||
Reference in New Issue
Block a user