@@ -8,12 +8,15 @@ import { URI } from '../../../../../../base/common/uri.js';
8
8
import { CHAT_CATEGORY } from '../../actions/chatActions.js' ;
9
9
import { IChatWidget , IChatWidgetService } from '../../chat.js' ;
10
10
import { KeyMod , KeyCode } from '../../../../../../base/common/keyCodes.js' ;
11
+ import { Registry } from '../../../../../../platform/registry/common/platform.js' ;
11
12
import { IViewsService } from '../../../../../services/views/common/viewsService.js' ;
12
13
import { isPromptFile } from '../../../../../../platform/prompts/common/constants.js' ;
14
+ import { LifecyclePhase } from '../../../../../services/lifecycle/common/lifecycle.js' ;
13
15
import { IEditorService } from '../../../../../services/editor/common/editorService.js' ;
14
16
import { ICommandService } from '../../../../../../platform/commands/common/commands.js' ;
15
17
import { appendToCommandPalette } from '../../../../files/browser/fileActions.contribution.js' ;
16
18
import { ServicesAccessor } from '../../../../../../platform/instantiation/common/instantiation.js' ;
19
+ import { IWorkbenchContributionsRegistry , Extensions } from '../../../../../common/contributions.js' ;
17
20
import { IActiveCodeEditor , isCodeEditor , isDiffEditor } from '../../../../../../editor/browser/editorBrowser.js' ;
18
21
import { KeybindingsRegistry , KeybindingWeight } from '../../../../../../platform/keybinding/common/keybindingsRegistry.js' ;
19
22
import { IChatAttachPromptActionOptions , ATTACH_PROMPT_ACTION_ID } from '../../actions/chatAttachPromptAction/chatAttachPromptAction.js' ;
@@ -63,27 +66,6 @@ const command = async (
63
66
await commandService . executeCommand ( ATTACH_PROMPT_ACTION_ID , options ) ;
64
67
} ;
65
68
66
- /**
67
- * Register the "Use Prompt" command with its keybinding.
68
- */
69
- KeybindingsRegistry . registerCommandAndKeybindingRule ( {
70
- id : COMMAND_ID ,
71
- weight : KeybindingWeight . WorkbenchContrib ,
72
- primary : COMMAND_KEY_BINDING ,
73
- handler : command ,
74
- } ) ;
75
-
76
- /**
77
- * Register the "Use Prompt" command in the `command palette`.
78
- */
79
- appendToCommandPalette (
80
- {
81
- id : COMMAND_ID ,
82
- title : localize ( 'commands.prompts.use.title' , "Use Prompt" ) ,
83
- category : CHAT_CATEGORY ,
84
- } ,
85
- ) ;
86
-
87
69
/**
88
70
* Get chat widget reference to attach prompt to.
89
71
*/
@@ -144,3 +126,30 @@ const getActivePromptUri = (
144
126
145
127
return undefined ;
146
128
} ;
129
+
130
+ /**
131
+ * Register the "Use Prompt" command with its keybinding.
132
+ */
133
+ KeybindingsRegistry . registerCommandAndKeybindingRule ( {
134
+ id : COMMAND_ID ,
135
+ weight : KeybindingWeight . WorkbenchContrib ,
136
+ primary : COMMAND_KEY_BINDING ,
137
+ handler : command ,
138
+ } ) ;
139
+
140
+ /**
141
+ * Register the "Use Prompt" command in the `command palette`.
142
+ */
143
+ appendToCommandPalette (
144
+ {
145
+ id : COMMAND_ID ,
146
+ title : localize ( 'commands.prompts.use.title' , "Use Prompt" ) ,
147
+ category : CHAT_CATEGORY ,
148
+ } ,
149
+ ) ;
150
+
151
+ class RunIfEnabled { }
152
+
153
+ // register the command as a workbench contribution
154
+ Registry . as < IWorkbenchContributionsRegistry > ( Extensions . Workbench )
155
+ . registerWorkbenchContribution ( RunIfEnabled , LifecyclePhase . Eventually ) ;
0 commit comments