@@ -16,8 +16,7 @@ struct CustomCommandView: View {
1616 " Real-time Suggestions " ,
1717 " Prefetch Suggestions " ,
1818 " Chat with Selection " ,
19- " Prompt to Code " ,
20- " # Custom Commands: " ,
19+ " Prompt to Code "
2120 ]
2221
2322 return existed + builtin
@@ -65,6 +64,7 @@ struct CustomCommandView: View {
6564 Spacer ( )
6665 Button ( action: {
6766 editingCommand = . init( isNew: true , command: CustomCommand (
67+ commandId: UUID ( ) . uuidString,
6868 name: " New Command " ,
6969 feature: . chatWithSelection(
7070 extraSystemPrompt: nil ,
@@ -236,6 +236,7 @@ struct EditCustomCommandView: View {
236236 }
237237
238238 lazy var newCommand = CustomCommand (
239+ commandId: editingCommand? . command. id ?? UUID ( ) . uuidString,
239240 name: name,
240241 feature: {
241242 switch commandType {
@@ -283,7 +284,7 @@ struct EditCustomCommandView: View {
283284 }
284285
285286 if let index = settings. customCommands. firstIndex ( where: {
286- $0. name == originalName
287+ $0. id == newCommand . id
287288 } ) {
288289 settings. customCommands [ index] = newCommand
289290 } else {
@@ -351,10 +352,12 @@ struct CustomCommandView_Preview: PreviewProvider {
351352 isOpen: . constant( true ) ,
352353 settings: . init( customCommands: . init( wrappedValue: [
353354 . init(
355+ commandId: " 1 " ,
354356 name: " Explain Code " ,
355357 feature: . chatWithSelection( extraSystemPrompt: nil , prompt: " Hello " )
356358 ) ,
357359 . init(
360+ commandId: " 2 " ,
358361 name: " Refactor Code " ,
359362 feature: . promptToCode(
360363 extraSystemPrompt: nil ,
@@ -363,6 +366,7 @@ struct CustomCommandView_Preview: PreviewProvider {
363366 )
364367 ) ,
365368 . init(
369+ commandId: " 3 " ,
366370 name: " Tell Me A Joke " ,
367371 feature: . customChat( systemPrompt: " Joke " , prompt: " " )
368372 ) ,
@@ -378,6 +382,7 @@ struct EditCustomCommandView_Preview: PreviewProvider {
378382 editingCommand: . constant( CustomCommandView . EditingCommand (
379383 isNew: false ,
380384 command: . init(
385+ commandId: " 4 " ,
381386 name: " Explain Code " ,
382387 feature: . promptToCode(
383388 extraSystemPrompt: nil ,
0 commit comments