2aceef7e0213fd55fedd0dec67c74f3b0b00bf2c4554be6811c54041b7bb5acb616e939ae14bb561d3bb5260db2de1e13f7968c1da6c30d96953dd2f29f4d2 1.7 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/cursor/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 /* KeybindingWeight.EditorCore */,
  18. kbExpr: EditorContextKeys.textInputFocus,
  19. primary: 2048 /* KeyMod.CtrlCmd */ | 42 /* KeyCode.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 /* CursorChangeReason.Explicit */, CursorMoveCommands.expandLineSelection(viewModel, viewModel.getCursorStates()));
  31. viewModel.revealPrimaryCursor(args.source, true);
  32. }
  33. }
  34. registerEditorAction(ExpandLineSelectionAction);