Path: blob/main/src/vs/editor/contrib/lineSelection/browser/lineSelection.ts
5272 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';1314interface ExpandLinesSelectionArgs {15source?: string;16}1718export class ExpandLineSelectionAction extends EditorAction {19constructor() {20super({21id: 'expandLineSelection',22label: nls.localize2('expandLineSelection', "Expand Line Selection"),23precondition: undefined,24kbOpts: {25weight: KeybindingWeight.EditorCore,26kbExpr: EditorContextKeys.textInputFocus,27primary: KeyMod.CtrlCmd | KeyCode.KeyL28},29});30}3132public run(_accessor: ServicesAccessor, editor: ICodeEditor, args: ExpandLinesSelectionArgs): void {33args = args || {};34if (!editor.hasModel()) {35return;36}37const viewModel = editor._getViewModel();38viewModel.model.pushStackElement();39viewModel.setCursorStates(40args.source,41CursorChangeReason.Explicit,42CursorMoveCommands.expandLineSelection(viewModel, viewModel.getCursorStates())43);44viewModel.revealAllCursors(args.source, true);45}46}4748registerEditorAction(ExpandLineSelectionAction);495051