59dfe7fcf6c7e5b7a58c5500a6d6ca386ccfd8921f731fd548deb84e632c4ea855c1844d19b9138d45a124dd1a07971b3deb44cdd2d2c649a210b0914d6f53 5.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  6. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  7. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  8. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  9. return c > 3 && r && Object.defineProperty(target, key, r), r;
  10. };
  11. var __param = (this && this.__param) || function (paramIndex, decorator) {
  12. return function (target, key) { decorator(target, key, paramIndex); }
  13. };
  14. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  15. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  16. return new (P || (P = Promise))(function (resolve, reject) {
  17. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  18. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  19. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  20. step((generator = generator.apply(thisArg, _arguments || [])).next());
  21. });
  22. };
  23. import { Registry } from '../../../../platform/registry/common/platform.js';
  24. import { Extensions } from '../../../../platform/quickinput/common/quickAccess.js';
  25. import { QuickCommandNLS } from '../../../common/standaloneStrings.js';
  26. import { ICodeEditorService } from '../../../browser/services/codeEditorService.js';
  27. import { AbstractEditorCommandsQuickAccessProvider } from '../../../contrib/quickAccess/browser/commandsQuickAccess.js';
  28. import { withNullAsUndefined } from '../../../../base/common/types.js';
  29. import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
  30. import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.js';
  31. import { ICommandService } from '../../../../platform/commands/common/commands.js';
  32. import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js';
  33. import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js';
  34. import { EditorAction, registerEditorAction } from '../../../browser/editorExtensions.js';
  35. import { EditorContextKeys } from '../../../common/editorContextKeys.js';
  36. import { IQuickInputService } from '../../../../platform/quickinput/common/quickInput.js';
  37. let StandaloneCommandsQuickAccessProvider = class StandaloneCommandsQuickAccessProvider extends AbstractEditorCommandsQuickAccessProvider {
  38. constructor(instantiationService, codeEditorService, keybindingService, commandService, telemetryService, dialogService) {
  39. super({ showAlias: false }, instantiationService, keybindingService, commandService, telemetryService, dialogService);
  40. this.codeEditorService = codeEditorService;
  41. }
  42. get activeTextEditorControl() { return withNullAsUndefined(this.codeEditorService.getFocusedCodeEditor()); }
  43. getCommandPicks() {
  44. return __awaiter(this, void 0, void 0, function* () {
  45. return this.getCodeEditorCommandPicks();
  46. });
  47. }
  48. };
  49. StandaloneCommandsQuickAccessProvider = __decorate([
  50. __param(0, IInstantiationService),
  51. __param(1, ICodeEditorService),
  52. __param(2, IKeybindingService),
  53. __param(3, ICommandService),
  54. __param(4, ITelemetryService),
  55. __param(5, IDialogService)
  56. ], StandaloneCommandsQuickAccessProvider);
  57. export { StandaloneCommandsQuickAccessProvider };
  58. export class GotoLineAction extends EditorAction {
  59. constructor() {
  60. super({
  61. id: GotoLineAction.ID,
  62. label: QuickCommandNLS.quickCommandActionLabel,
  63. alias: 'Command Palette',
  64. precondition: undefined,
  65. kbOpts: {
  66. kbExpr: EditorContextKeys.focus,
  67. primary: 59 /* KeyCode.F1 */,
  68. weight: 100 /* KeybindingWeight.EditorContrib */
  69. },
  70. contextMenuOpts: {
  71. group: 'z_commands',
  72. order: 1
  73. }
  74. });
  75. }
  76. run(accessor) {
  77. accessor.get(IQuickInputService).quickAccess.show(StandaloneCommandsQuickAccessProvider.PREFIX);
  78. }
  79. }
  80. GotoLineAction.ID = 'editor.action.quickCommand';
  81. registerEditorAction(GotoLineAction);
  82. Registry.as(Extensions.Quickaccess).registerQuickAccessProvider({
  83. ctor: StandaloneCommandsQuickAccessProvider,
  84. prefix: StandaloneCommandsQuickAccessProvider.PREFIX,
  85. helpEntries: [{ description: QuickCommandNLS.quickCommandHelp, commandId: GotoLineAction.ID }]
  86. });