Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/editor/contrib/lineSelection/browser/lineSelection.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { KeyCode, KeyMod } from '../../../../base/common/keyCodes.js';
7
import { ICodeEditor } from '../../../browser/editorBrowser.js';
8
import { EditorAction, registerEditorAction, ServicesAccessor } from '../../../browser/editorExtensions.js';
9
import { CursorChangeReason } from '../../../common/cursorEvents.js';
10
import { CursorMoveCommands } from '../../../common/cursor/cursorMoveCommands.js';
11
import { EditorContextKeys } from '../../../common/editorContextKeys.js';
12
import * as nls from '../../../../nls.js';
13
import { KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js';
14
15
export class ExpandLineSelectionAction extends EditorAction {
16
constructor() {
17
super({
18
id: 'expandLineSelection',
19
label: nls.localize2('expandLineSelection', "Expand Line Selection"),
20
precondition: undefined,
21
kbOpts: {
22
weight: KeybindingWeight.EditorCore,
23
kbExpr: EditorContextKeys.textInputFocus,
24
primary: KeyMod.CtrlCmd | KeyCode.KeyL
25
},
26
});
27
}
28
29
public run(_accessor: ServicesAccessor, editor: ICodeEditor, args: any): void {
30
args = args || {};
31
if (!editor.hasModel()) {
32
return;
33
}
34
const viewModel = editor._getViewModel();
35
viewModel.model.pushStackElement();
36
viewModel.setCursorStates(
37
args.source,
38
CursorChangeReason.Explicit,
39
CursorMoveCommands.expandLineSelection(viewModel, viewModel.getCursorStates())
40
);
41
viewModel.revealAllCursors(args.source, true);
42
}
43
}
44
45
registerEditorAction(ExpandLineSelectionAction);
46
47