@@ -7,7 +7,7 @@ import { isEqual } from '../../../../../base/common/resources.js';
7
7
import { URI } from '../../../../../base/common/uri.js' ;
8
8
import { getCodeEditor } from '../../../../../editor/browser/editorBrowser.js' ;
9
9
import { SnippetController2 } from '../../../../../editor/contrib/snippet/browser/snippetController2.js' ;
10
- import { localize } from '../../../../../nls.js' ;
10
+ import { localize , localize2 } from '../../../../../nls.js' ;
11
11
import { Action2 , MenuId , registerAction2 } from '../../../../../platform/actions/common/actions.js' ;
12
12
import { ICommandService } from '../../../../../platform/commands/common/commands.js' ;
13
13
import { ContextKeyExpr } from '../../../../../platform/contextkey/common/contextkey.js' ;
@@ -168,8 +168,52 @@ class NewModeFileAction extends AbstractNewPromptFileAction {
168
168
}
169
169
}
170
170
171
+ class NewUntitledPromptFileAction extends Action2 {
172
+ constructor ( ) {
173
+ super ( {
174
+ id : 'workbench.command.new.untitled.prompt' ,
175
+ title : localize2 ( 'commands.new.untitled.prompt.title' , "New Untitled Prompt File" ) ,
176
+ f1 : true ,
177
+ precondition : ContextKeyExpr . and ( PromptsConfig . enabledCtx , ChatContextKeys . enabled ) ,
178
+ category : CHAT_CATEGORY ,
179
+ keybinding : {
180
+ weight : KeybindingWeight . WorkbenchContrib
181
+ } ,
182
+ } ) ;
183
+ }
184
+
185
+ public override async run ( accessor : ServicesAccessor ) {
186
+ const editorService = accessor . get ( IEditorService ) ;
187
+ const snippetService = accessor . get ( ISnippetsService ) ;
188
+
189
+ const languageId = getLanguageIdForPromptsType ( PromptsType . prompt ) ;
190
+
191
+ const input = await editorService . openEditor ( {
192
+ resource : undefined ,
193
+ languageId,
194
+ options : {
195
+ pinned : true
196
+ }
197
+ } ) ;
198
+
199
+ const editor = getCodeEditor ( editorService . activeTextEditorControl ) ;
200
+ if ( editor && editor . hasModel ( ) ) {
201
+ const snippets = await snippetService . getSnippets ( languageId , { fileTemplateSnippets : true , noRecencySort : true , includeNoPrefixSnippets : true } ) ;
202
+ if ( snippets . length > 0 ) {
203
+ SnippetController2 . get ( editor ) ?. apply ( [ {
204
+ range : editor . getModel ( ) . getFullModelRange ( ) ,
205
+ template : snippets [ 0 ] . body
206
+ } ] ) ;
207
+ }
208
+ }
209
+
210
+ return input ;
211
+ }
212
+ }
213
+
171
214
export function registerNewPromptFileActions ( ) : void {
172
215
registerAction2 ( NewPromptFileAction ) ;
173
216
registerAction2 ( NewInstructionsFileAction ) ;
174
217
registerAction2 ( NewModeFileAction ) ;
218
+ registerAction2 ( NewUntitledPromptFileAction ) ;
175
219
}
0 commit comments