@@ -3,10 +3,9 @@ use std::sync::Arc;
33
44use forge_select:: { ForgeWidget , PreviewLayout , PreviewPlacement , SelectRow } ;
55use forge_walker:: Walker ;
6- use reedline:: { Completer , Span , Suggestion } ;
76
87use crate :: completer:: CommandCompleter ;
9- use crate :: completer:: search_term:: SearchTerm ;
8+ use crate :: completer:: search_term:: { SearchTerm , Span } ;
109use crate :: model:: ForgeCommandManager ;
1110
1211pub fn select_workspace_file ( cwd : & Path , query : Option < String > ) -> anyhow:: Result < Option < String > > {
@@ -60,14 +59,18 @@ pub struct InputCompleter {
6059 command : CommandCompleter ,
6160}
6261
62+ pub struct InputSuggestion {
63+ pub value : String ,
64+ pub span : Span ,
65+ pub append_whitespace : bool ,
66+ }
67+
6368impl InputCompleter {
6469 pub fn new ( cwd : PathBuf , command_manager : Arc < ForgeCommandManager > ) -> Self {
6570 Self { cwd, command : CommandCompleter :: new ( command_manager) }
6671 }
67- }
6872
69- impl Completer for InputCompleter {
70- fn complete ( & mut self , line : & str , pos : usize ) -> Vec < Suggestion > {
73+ pub fn complete ( & mut self , line : & str , pos : usize ) -> Vec < InputSuggestion > {
7174 if line. starts_with ( '/' ) || line. starts_with ( ':' ) {
7275 // if the line starts with '/' or ':' it's probably a command, so we delegate to
7376 // the command completer.
@@ -86,15 +89,10 @@ impl Completer for InputCompleter {
8689
8790 if let Ok ( Some ( selected) ) = select_workspace_file ( & self . cwd , initial_text) {
8891 let value = format ! ( "[{}]" , selected) ;
89- return vec ! [ Suggestion {
90- description: None ,
92+ return vec ! [ InputSuggestion {
9193 value,
92- style: None ,
93- extra: None ,
9494 span: Span :: new( query. span. start, query. span. end) ,
9595 append_whitespace: true ,
96- match_indices: None ,
97- display_override: None ,
9896 } ] ;
9997 }
10098 }
0 commit comments