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