lineSelection.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  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. import { EditorAction, registerEditorAction } from '../../browser/editorExtensions.js';
  6. import { CursorMoveCommands } from '../../common/controller/cursorMoveCommands.js';
  7. import { EditorContextKeys } from '../../common/editorContextKeys.js';
  8. import * as nls from '../../../nls.js';
  9. export class ExpandLineSelectionAction extends EditorAction {
  10. constructor() {
  11. super({
  12. id: 'expandLineSelection',
  13. label: nls.localize('expandLineSelection', "Expand Line Selection"),
  14. alias: 'Expand Line Selection',
  15. precondition: undefined,
  16. kbOpts: {
  17. weight: 0 /* EditorCore */,
  18. kbExpr: EditorContextKeys.textInputFocus,
  19. primary: 2048 /* CtrlCmd */ | 42 /* KeyL */
  20. },
  21. });
  22. }
  23. run(_accessor, editor, args) {
  24. args = args || {};
  25. if (!editor.hasModel()) {
  26. return;
  27. }
  28. const viewModel = editor._getViewModel();
  29. viewModel.model.pushStackElement();
  30. viewModel.setCursorStates(args.source, 3 /* Explicit */, CursorMoveCommands.expandLineSelection(viewModel, viewModel.getCursorStates()));
  31. viewModel.revealPrimaryCursor(args.source, true);
  32. }
  33. }
  34. registerEditorAction(ExpandLineSelectionAction);