6848790fca14bce46dbc391473a7f1ad33badaa362e05bc38eee82a8cf4eb9e66bea021b039aa536e9f3ad5134f4761f6bb6a34dd62e6865f87ef368939313 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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 { CancellationToken } from '../../../../base/common/cancellation.js';
  24. import { Lazy } from '../../../../base/common/lazy.js';
  25. import { Disposable } from '../../../../base/common/lifecycle.js';
  26. import { escapeRegExpCharacters } from '../../../../base/common/strings.js';
  27. import { EditorAction, EditorCommand, registerEditorCommand } from '../../../browser/editorExtensions.js';
  28. import { IBulkEditService, ResourceEdit } from '../../../browser/services/bulkEditService.js';
  29. import { EditorContextKeys } from '../../../common/editorContextKeys.js';
  30. import { ILanguageFeaturesService } from '../../../common/services/languageFeatures.js';
  31. import { codeActionCommandId, fixAllCommandId, organizeImportsCommandId, refactorCommandId, refactorPreviewCommandId, sourceActionCommandId } from './codeAction.js';
  32. import { CodeActionUi } from './codeActionUi.js';
  33. import { MessageController } from '../../message/browser/messageController.js';
  34. import * as nls from '../../../../nls.js';
  35. import { ICommandService } from '../../../../platform/commands/common/commands.js';
  36. import { ContextKeyExpr, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
  37. import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
  38. import { IMarkerService } from '../../../../platform/markers/common/markers.js';
  39. import { IEditorProgressService } from '../../../../platform/progress/common/progress.js';
  40. import { INotificationService } from '../../../../platform/notification/common/notification.js';
  41. import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js';
  42. import { CodeActionModel, SUPPORTED_CODE_ACTIONS } from './codeActionModel.js';
  43. import { CodeActionCommandArgs, CodeActionKind, CodeActionTriggerSource } from './types.js';
  44. import { Context } from './codeActionMenu.js';
  45. function contextKeyForSupportedActions(kind) {
  46. return ContextKeyExpr.regex(SUPPORTED_CODE_ACTIONS.keys()[0], new RegExp('(\\s|^)' + escapeRegExpCharacters(kind.value) + '\\b'));
  47. }
  48. function refactorTrigger(editor, userArgs, preview, codeActionFrom) {
  49. const args = CodeActionCommandArgs.fromUser(userArgs, {
  50. kind: CodeActionKind.Refactor,
  51. apply: "never" /* CodeActionAutoApply.Never */
  52. });
  53. return triggerCodeActionsForEditorSelection(editor, typeof (userArgs === null || userArgs === void 0 ? void 0 : userArgs.kind) === 'string'
  54. ? args.preferred
  55. ? nls.localize('editor.action.refactor.noneMessage.preferred.kind', "No preferred refactorings for '{0}' available", userArgs.kind)
  56. : nls.localize('editor.action.refactor.noneMessage.kind', "No refactorings for '{0}' available", userArgs.kind)
  57. : args.preferred
  58. ? nls.localize('editor.action.refactor.noneMessage.preferred', "No preferred refactorings available")
  59. : nls.localize('editor.action.refactor.noneMessage', "No refactorings available"), {
  60. include: CodeActionKind.Refactor.contains(args.kind) ? args.kind : CodeActionKind.None,
  61. onlyIncludePreferredActions: args.preferred
  62. }, args.apply, preview, codeActionFrom);
  63. }
  64. const argsSchema = {
  65. type: 'object',
  66. defaultSnippets: [{ body: { kind: '' } }],
  67. properties: {
  68. 'kind': {
  69. type: 'string',
  70. description: nls.localize('args.schema.kind', "Kind of the code action to run."),
  71. },
  72. 'apply': {
  73. type: 'string',
  74. description: nls.localize('args.schema.apply', "Controls when the returned actions are applied."),
  75. default: "ifSingle" /* CodeActionAutoApply.IfSingle */,
  76. enum: ["first" /* CodeActionAutoApply.First */, "ifSingle" /* CodeActionAutoApply.IfSingle */, "never" /* CodeActionAutoApply.Never */],
  77. enumDescriptions: [
  78. nls.localize('args.schema.apply.first', "Always apply the first returned code action."),
  79. nls.localize('args.schema.apply.ifSingle', "Apply the first returned code action if it is the only one."),
  80. nls.localize('args.schema.apply.never', "Do not apply the returned code actions."),
  81. ]
  82. },
  83. 'preferred': {
  84. type: 'boolean',
  85. default: false,
  86. description: nls.localize('args.schema.preferred', "Controls if only preferred code actions should be returned."),
  87. }
  88. }
  89. };
  90. let QuickFixController = class QuickFixController extends Disposable {
  91. constructor(editor, markerService, contextKeyService, progressService, _instantiationService, languageFeaturesService) {
  92. super();
  93. this._instantiationService = _instantiationService;
  94. this._editor = editor;
  95. this._model = this._register(new CodeActionModel(this._editor, languageFeaturesService.codeActionProvider, markerService, contextKeyService, progressService));
  96. this._register(this._model.onDidChangeState(newState => this.update(newState)));
  97. this._ui = new Lazy(() => this._register(new CodeActionUi(editor, QuickFixAction.Id, AutoFixAction.Id, {
  98. applyCodeAction: (action, retrigger, preview) => __awaiter(this, void 0, void 0, function* () {
  99. try {
  100. yield this._applyCodeAction(action, preview);
  101. }
  102. finally {
  103. if (retrigger) {
  104. this._trigger({ type: 2 /* CodeActionTriggerType.Auto */, triggerAction: CodeActionTriggerSource.QuickFix, filter: {} });
  105. }
  106. }
  107. })
  108. }, this._instantiationService)));
  109. }
  110. static get(editor) {
  111. return editor.getContribution(QuickFixController.ID);
  112. }
  113. update(newState) {
  114. this._ui.getValue().update(newState);
  115. }
  116. hideCodeActionMenu() {
  117. if (this._ui.hasValue()) {
  118. this._ui.getValue().hideCodeActionWidget();
  119. }
  120. }
  121. navigateCodeActionList(navUp) {
  122. if (this._ui.hasValue()) {
  123. this._ui.getValue().navigateList(navUp);
  124. }
  125. }
  126. selectedOption() {
  127. if (this._ui.hasValue()) {
  128. this._ui.getValue().onEnter();
  129. }
  130. }
  131. selectedOptionWithPreview() {
  132. if (this._ui.hasValue()) {
  133. this._ui.getValue().onPreviewEnter();
  134. }
  135. }
  136. showCodeActions(trigger, actions, at) {
  137. return this._ui.getValue().showCodeActionList(trigger, actions, at, { includeDisabledActions: false, fromLightbulb: false });
  138. }
  139. manualTriggerAtCurrentPosition(notAvailableMessage, triggerAction, filter, autoApply, preview) {
  140. var _a;
  141. if (!this._editor.hasModel()) {
  142. return;
  143. }
  144. (_a = MessageController.get(this._editor)) === null || _a === void 0 ? void 0 : _a.closeMessage();
  145. const triggerPosition = this._editor.getPosition();
  146. this._trigger({ type: 1 /* CodeActionTriggerType.Invoke */, triggerAction, filter, autoApply, context: { notAvailableMessage, position: triggerPosition }, preview });
  147. }
  148. _trigger(trigger) {
  149. return this._model.trigger(trigger);
  150. }
  151. _applyCodeAction(action, preview) {
  152. return this._instantiationService.invokeFunction(applyCodeAction, action, ApplyCodeActionReason.FromCodeActions, { preview, editor: this._editor });
  153. }
  154. };
  155. QuickFixController.ID = 'editor.contrib.quickFixController';
  156. QuickFixController = __decorate([
  157. __param(1, IMarkerService),
  158. __param(2, IContextKeyService),
  159. __param(3, IEditorProgressService),
  160. __param(4, IInstantiationService),
  161. __param(5, ILanguageFeaturesService)
  162. ], QuickFixController);
  163. export { QuickFixController };
  164. export var ApplyCodeActionReason;
  165. (function (ApplyCodeActionReason) {
  166. ApplyCodeActionReason["OnSave"] = "onSave";
  167. ApplyCodeActionReason["FromProblemsView"] = "fromProblemsView";
  168. ApplyCodeActionReason["FromCodeActions"] = "fromCodeActions";
  169. })(ApplyCodeActionReason || (ApplyCodeActionReason = {}));
  170. export function applyCodeAction(accessor, item, codeActionReason, options) {
  171. return __awaiter(this, void 0, void 0, function* () {
  172. const bulkEditService = accessor.get(IBulkEditService);
  173. const commandService = accessor.get(ICommandService);
  174. const telemetryService = accessor.get(ITelemetryService);
  175. const notificationService = accessor.get(INotificationService);
  176. telemetryService.publicLog2('codeAction.applyCodeAction', {
  177. codeActionTitle: item.action.title,
  178. codeActionKind: item.action.kind,
  179. codeActionIsPreferred: !!item.action.isPreferred,
  180. reason: codeActionReason,
  181. });
  182. yield item.resolve(CancellationToken.None);
  183. if (item.action.edit) {
  184. yield bulkEditService.apply(ResourceEdit.convert(item.action.edit), {
  185. editor: options === null || options === void 0 ? void 0 : options.editor,
  186. label: item.action.title,
  187. quotableLabel: item.action.title,
  188. code: 'undoredo.codeAction',
  189. respectAutoSaveConfig: true,
  190. showPreview: options === null || options === void 0 ? void 0 : options.preview,
  191. });
  192. }
  193. if (item.action.command) {
  194. try {
  195. yield commandService.executeCommand(item.action.command.id, ...(item.action.command.arguments || []));
  196. }
  197. catch (err) {
  198. const message = asMessage(err);
  199. notificationService.error(typeof message === 'string'
  200. ? message
  201. : nls.localize('applyCodeActionFailed', "An unknown error occurred while applying the code action"));
  202. }
  203. }
  204. });
  205. }
  206. function asMessage(err) {
  207. if (typeof err === 'string') {
  208. return err;
  209. }
  210. else if (err instanceof Error && typeof err.message === 'string') {
  211. return err.message;
  212. }
  213. else {
  214. return undefined;
  215. }
  216. }
  217. function triggerCodeActionsForEditorSelection(editor, notAvailableMessage, filter, autoApply, preview = false, triggerAction = CodeActionTriggerSource.Default) {
  218. if (editor.hasModel()) {
  219. const controller = QuickFixController.get(editor);
  220. controller === null || controller === void 0 ? void 0 : controller.manualTriggerAtCurrentPosition(notAvailableMessage, triggerAction, filter, autoApply, preview);
  221. }
  222. }
  223. export class QuickFixAction extends EditorAction {
  224. constructor() {
  225. super({
  226. id: QuickFixAction.Id,
  227. label: nls.localize('quickfix.trigger.label', "Quick Fix..."),
  228. alias: 'Quick Fix...',
  229. precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasCodeActionsProvider),
  230. kbOpts: {
  231. kbExpr: EditorContextKeys.editorTextFocus,
  232. primary: 2048 /* KeyMod.CtrlCmd */ | 84 /* KeyCode.Period */,
  233. weight: 100 /* KeybindingWeight.EditorContrib */
  234. }
  235. });
  236. }
  237. run(_accessor, editor) {
  238. return triggerCodeActionsForEditorSelection(editor, nls.localize('editor.action.quickFix.noneMessage', "No code actions available"), undefined, undefined, false, CodeActionTriggerSource.QuickFix);
  239. }
  240. }
  241. QuickFixAction.Id = 'editor.action.quickFix';
  242. export class CodeActionCommand extends EditorCommand {
  243. constructor() {
  244. super({
  245. id: codeActionCommandId,
  246. precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasCodeActionsProvider),
  247. description: {
  248. description: 'Trigger a code action',
  249. args: [{ name: 'args', schema: argsSchema, }]
  250. }
  251. });
  252. }
  253. runEditorCommand(_accessor, editor, userArgs) {
  254. const args = CodeActionCommandArgs.fromUser(userArgs, {
  255. kind: CodeActionKind.Empty,
  256. apply: "ifSingle" /* CodeActionAutoApply.IfSingle */,
  257. });
  258. return triggerCodeActionsForEditorSelection(editor, typeof (userArgs === null || userArgs === void 0 ? void 0 : userArgs.kind) === 'string'
  259. ? args.preferred
  260. ? nls.localize('editor.action.codeAction.noneMessage.preferred.kind', "No preferred code actions for '{0}' available", userArgs.kind)
  261. : nls.localize('editor.action.codeAction.noneMessage.kind', "No code actions for '{0}' available", userArgs.kind)
  262. : args.preferred
  263. ? nls.localize('editor.action.codeAction.noneMessage.preferred', "No preferred code actions available")
  264. : nls.localize('editor.action.codeAction.noneMessage', "No code actions available"), {
  265. include: args.kind,
  266. includeSourceActions: true,
  267. onlyIncludePreferredActions: args.preferred,
  268. }, args.apply);
  269. }
  270. }
  271. export class RefactorAction extends EditorAction {
  272. constructor() {
  273. super({
  274. id: refactorCommandId,
  275. label: nls.localize('refactor.label', "Refactor..."),
  276. alias: 'Refactor...',
  277. precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasCodeActionsProvider),
  278. kbOpts: {
  279. kbExpr: EditorContextKeys.editorTextFocus,
  280. primary: 2048 /* KeyMod.CtrlCmd */ | 1024 /* KeyMod.Shift */ | 48 /* KeyCode.KeyR */,
  281. mac: {
  282. primary: 256 /* KeyMod.WinCtrl */ | 1024 /* KeyMod.Shift */ | 48 /* KeyCode.KeyR */
  283. },
  284. weight: 100 /* KeybindingWeight.EditorContrib */
  285. },
  286. contextMenuOpts: {
  287. group: '1_modification',
  288. order: 2,
  289. when: ContextKeyExpr.and(EditorContextKeys.writable, contextKeyForSupportedActions(CodeActionKind.Refactor)),
  290. },
  291. description: {
  292. description: 'Refactor...',
  293. args: [{ name: 'args', schema: argsSchema }]
  294. }
  295. });
  296. }
  297. run(_accessor, editor, userArgs) {
  298. return refactorTrigger(editor, userArgs, false, CodeActionTriggerSource.Refactor);
  299. }
  300. }
  301. export class RefactorPreview extends EditorAction {
  302. constructor() {
  303. super({
  304. id: refactorPreviewCommandId,
  305. label: nls.localize('refactor.preview.label', "Refactor with Preview..."),
  306. alias: 'Refactor Preview...',
  307. precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasCodeActionsProvider),
  308. description: {
  309. description: 'Refactor Preview...',
  310. args: [{ name: 'args', schema: argsSchema }]
  311. }
  312. });
  313. }
  314. run(_accessor, editor, userArgs) {
  315. return refactorTrigger(editor, userArgs, true, CodeActionTriggerSource.RefactorPreview);
  316. }
  317. }
  318. export class SourceAction extends EditorAction {
  319. constructor() {
  320. super({
  321. id: sourceActionCommandId,
  322. label: nls.localize('source.label', "Source Action..."),
  323. alias: 'Source Action...',
  324. precondition: ContextKeyExpr.and(EditorContextKeys.writable, EditorContextKeys.hasCodeActionsProvider),
  325. contextMenuOpts: {
  326. group: '1_modification',
  327. order: 2.1,
  328. when: ContextKeyExpr.and(EditorContextKeys.writable, contextKeyForSupportedActions(CodeActionKind.Source)),
  329. },
  330. description: {
  331. description: 'Source Action...',
  332. args: [{ name: 'args', schema: argsSchema }]
  333. }
  334. });
  335. }
  336. run(_accessor, editor, userArgs) {
  337. const args = CodeActionCommandArgs.fromUser(userArgs, {
  338. kind: CodeActionKind.Source,
  339. apply: "never" /* CodeActionAutoApply.Never */
  340. });
  341. return triggerCodeActionsForEditorSelection(editor, typeof (userArgs === null || userArgs === void 0 ? void 0 : userArgs.kind) === 'string'
  342. ? args.preferred
  343. ? nls.localize('editor.action.source.noneMessage.preferred.kind', "No preferred source actions for '{0}' available", userArgs.kind)
  344. : nls.localize('editor.action.source.noneMessage.kind', "No source actions for '{0}' available", userArgs.kind)
  345. : args.preferred
  346. ? nls.localize('editor.action.source.noneMessage.preferred', "No preferred source actions available")
  347. : nls.localize('editor.action.source.noneMessage', "No source actions available"), {
  348. include: CodeActionKind.Source.contains(args.kind) ? args.kind : CodeActionKind.None,
  349. includeSourceActions: true,
  350. onlyIncludePreferredActions: args.preferred,
  351. }, args.apply, undefined, CodeActionTriggerSource.SourceAction);
  352. }
  353. }
  354. export class OrganizeImportsAction extends EditorAction {
  355. constructor() {
  356. super({
  357. id: organizeImportsCommandId,
  358. label: nls.localize('organizeImports.label', "Organize Imports"),
  359. alias: 'Organize Imports',
  360. precondition: ContextKeyExpr.and(EditorContextKeys.writable, contextKeyForSupportedActions(CodeActionKind.SourceOrganizeImports)),
  361. kbOpts: {
  362. kbExpr: EditorContextKeys.editorTextFocus,
  363. primary: 1024 /* KeyMod.Shift */ | 512 /* KeyMod.Alt */ | 45 /* KeyCode.KeyO */,
  364. weight: 100 /* KeybindingWeight.EditorContrib */
  365. },
  366. });
  367. }
  368. run(_accessor, editor) {
  369. return triggerCodeActionsForEditorSelection(editor, nls.localize('editor.action.organize.noneMessage', "No organize imports action available"), { include: CodeActionKind.SourceOrganizeImports, includeSourceActions: true }, "ifSingle" /* CodeActionAutoApply.IfSingle */, undefined, CodeActionTriggerSource.OrganizeImports);
  370. }
  371. }
  372. export class FixAllAction extends EditorAction {
  373. constructor() {
  374. super({
  375. id: fixAllCommandId,
  376. label: nls.localize('fixAll.label', "Fix All"),
  377. alias: 'Fix All',
  378. precondition: ContextKeyExpr.and(EditorContextKeys.writable, contextKeyForSupportedActions(CodeActionKind.SourceFixAll))
  379. });
  380. }
  381. run(_accessor, editor) {
  382. return triggerCodeActionsForEditorSelection(editor, nls.localize('fixAll.noneMessage', "No fix all action available"), { include: CodeActionKind.SourceFixAll, includeSourceActions: true }, "ifSingle" /* CodeActionAutoApply.IfSingle */, undefined, CodeActionTriggerSource.FixAll);
  383. }
  384. }
  385. export class AutoFixAction extends EditorAction {
  386. constructor() {
  387. super({
  388. id: AutoFixAction.Id,
  389. label: nls.localize('autoFix.label', "Auto Fix..."),
  390. alias: 'Auto Fix...',
  391. precondition: ContextKeyExpr.and(EditorContextKeys.writable, contextKeyForSupportedActions(CodeActionKind.QuickFix)),
  392. kbOpts: {
  393. kbExpr: EditorContextKeys.editorTextFocus,
  394. primary: 512 /* KeyMod.Alt */ | 1024 /* KeyMod.Shift */ | 84 /* KeyCode.Period */,
  395. mac: {
  396. primary: 2048 /* KeyMod.CtrlCmd */ | 512 /* KeyMod.Alt */ | 84 /* KeyCode.Period */
  397. },
  398. weight: 100 /* KeybindingWeight.EditorContrib */
  399. }
  400. });
  401. }
  402. run(_accessor, editor) {
  403. return triggerCodeActionsForEditorSelection(editor, nls.localize('editor.action.autoFix.noneMessage', "No auto fixes available"), {
  404. include: CodeActionKind.QuickFix,
  405. onlyIncludePreferredActions: true
  406. }, "ifSingle" /* CodeActionAutoApply.IfSingle */, undefined, CodeActionTriggerSource.AutoFix);
  407. }
  408. }
  409. AutoFixAction.Id = 'editor.action.autoFix';
  410. const CodeActionContribution = EditorCommand.bindToContribution(QuickFixController.get);
  411. const weight = 100 /* KeybindingWeight.EditorContrib */ + 90;
  412. registerEditorCommand(new CodeActionContribution({
  413. id: 'hideCodeActionMenuWidget',
  414. precondition: Context.Visible,
  415. handler(x) {
  416. x.hideCodeActionMenu();
  417. },
  418. kbOpts: {
  419. weight: weight,
  420. primary: 9 /* KeyCode.Escape */,
  421. secondary: [1024 /* KeyMod.Shift */ | 9 /* KeyCode.Escape */]
  422. }
  423. }));
  424. registerEditorCommand(new CodeActionContribution({
  425. id: 'focusPreviousCodeAction',
  426. precondition: Context.Visible,
  427. handler(x) {
  428. x.navigateCodeActionList(true);
  429. },
  430. kbOpts: {
  431. weight: weight + 100000,
  432. primary: 16 /* KeyCode.UpArrow */,
  433. secondary: [2048 /* KeyMod.CtrlCmd */ | 16 /* KeyCode.UpArrow */],
  434. }
  435. }));
  436. registerEditorCommand(new CodeActionContribution({
  437. id: 'focusNextCodeAction',
  438. precondition: Context.Visible,
  439. handler(x) {
  440. x.navigateCodeActionList(false);
  441. },
  442. kbOpts: {
  443. weight: weight + 100000,
  444. primary: 18 /* KeyCode.DownArrow */,
  445. secondary: [2048 /* KeyMod.CtrlCmd */ | 18 /* KeyCode.DownArrow */],
  446. }
  447. }));
  448. registerEditorCommand(new CodeActionContribution({
  449. id: 'onEnterSelectCodeAction',
  450. precondition: Context.Visible,
  451. handler(x) {
  452. x.selectedOption();
  453. },
  454. kbOpts: {
  455. weight: weight + 100000,
  456. primary: 3 /* KeyCode.Enter */,
  457. secondary: [1024 /* KeyMod.Shift */ | 2 /* KeyCode.Tab */],
  458. }
  459. }));
  460. registerEditorCommand(new CodeActionContribution({
  461. id: 'onEnterSelectCodeActionWithPreview',
  462. precondition: Context.Visible,
  463. handler(x) {
  464. x.selectedOptionWithPreview();
  465. },
  466. kbOpts: {
  467. weight: weight + 100000,
  468. primary: 2048 /* KeyMod.CtrlCmd */ | 3 /* KeyCode.Enter */,
  469. }
  470. }));