Merge commit 'be3e8236086165e5e45a5a10783823874b3f3ebd' as 'lib/vscode'

This commit is contained in:
Joe Previte
2020-12-15 15:52:33 -07:00
4649 changed files with 1311795 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { EditorAction, IActionOptions, ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions';
import { ICommand } from 'vs/editor/common/editorCommon';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { MoveCaretCommand } from 'vs/editor/contrib/caretOperations/moveCaretCommand';
class MoveCaretAction extends EditorAction {
private readonly left: boolean;
constructor(left: boolean, opts: IActionOptions) {
super(opts);
this.left = left;
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
if (!editor.hasModel()) {
return;
}
let commands: ICommand[] = [];
let selections = editor.getSelections();
for (const selection of selections) {
commands.push(new MoveCaretCommand(selection, this.left));
}
editor.pushUndoStop();
editor.executeCommands(this.id, commands);
editor.pushUndoStop();
}
}
class MoveCaretLeftAction extends MoveCaretAction {
constructor() {
super(true, {
id: 'editor.action.moveCarretLeftAction',
label: nls.localize('caret.moveLeft', "Move Selected Text Left"),
alias: 'Move Selected Text Left',
precondition: EditorContextKeys.writable
});
}
}
class MoveCaretRightAction extends MoveCaretAction {
constructor() {
super(false, {
id: 'editor.action.moveCarretRightAction',
label: nls.localize('caret.moveRight', "Move Selected Text Right"),
alias: 'Move Selected Text Right',
precondition: EditorContextKeys.writable
});
}
}
registerEditorAction(MoveCaretLeftAction);
registerEditorAction(MoveCaretRightAction);