@@ -355,29 +355,7 @@ struct ChatPanelInputArea: View {
355355 text: $typedMessage,
356356 font: . systemFont( ofSize: 14 ) ,
357357 onSubmit: { submitText ( ) } ,
358- completions: { text, _, range in
359- if text. isEmpty { return [ ] }
360- let availableFeatures = [
361- " /run " ,
362- " /airun " ,
363- " /math " ,
364- " /search " ,
365- " /shortcut " ,
366- " /exit " ,
367- " @selection " ,
368- " @file " ,
369- ]
370- return availableFeatures
371- . filter { $0. hasPrefix ( text) && $0 != text }
372- . compactMap {
373- guard let index = $0. index (
374- $0. startIndex,
375- offsetBy: range. location,
376- limitedBy: $0. endIndex
377- ) else { return nil }
378- return String ( $0 [ index... ] )
379- }
380- }
358+ completions: chatAutoCompletion
381359 )
382360 . padding ( . top, 1 )
383361 . padding ( . bottom, - 1 )
@@ -420,6 +398,26 @@ struct ChatPanelInputArea: View {
420398 chat. send ( typedMessage)
421399 typedMessage = " "
422400 }
401+
402+ func chatAutoCompletion( text: String , proposed: [ String ] , range: NSRange ) -> [ String ] {
403+ if text. isEmpty { return [ ] }
404+ let plugins = chat. pluginIdentifiers. map { " / \( $0) " }
405+ let availableFeatures = plugins + [
406+ " /exit " ,
407+ " @selection " ,
408+ " @file " ,
409+ ]
410+ return availableFeatures
411+ . filter { $0. hasPrefix ( text) && $0 != text }
412+ . compactMap {
413+ guard let index = $0. index (
414+ $0. startIndex,
415+ offsetBy: range. location,
416+ limitedBy: $0. endIndex
417+ ) else { return nil }
418+ return String ( $0 [ index... ] )
419+ }
420+ }
423421}
424422
425423struct ChatContextMenu : View {
@@ -700,3 +698,6 @@ struct ChatPanel_Light_Preview: PreviewProvider {
700698 }
701699}
702700
701+
702+
703+
0 commit comments