File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ impl Modal for McpManagerModal {
2929
3030 fn handle_paste ( & mut self , text : & str ) -> bool {
3131 match & mut self . mode {
32+ McpMode :: List => {
33+ self . list . append_search_text ( text) ;
34+ true
35+ }
3236 McpMode :: AddStdioServer {
3337 name,
3438 command,
@@ -190,3 +194,37 @@ impl Modal for McpManagerModal {
190194 Some ( "Search servers..." )
191195 }
192196}
197+
198+ #[ cfg( test) ]
199+ mod tests {
200+ use super :: * ;
201+
202+ #[ test]
203+ fn test_list_mode_paste_updates_search_query ( ) {
204+ let mut modal = McpManagerModal :: new ( vec ! [
205+ McpServerInfo {
206+ name: "filesystem" . to_string( ) ,
207+ status: McpStatus :: Running ,
208+ tool_count: 3 ,
209+ error: None ,
210+ requires_auth: false ,
211+ } ,
212+ McpServerInfo {
213+ name: "github" . to_string( ) ,
214+ status: McpStatus :: Stopped ,
215+ tool_count: 8 ,
216+ error: None ,
217+ requires_auth: false ,
218+ } ,
219+ ] ) ;
220+
221+ assert ! ( modal. handle_paste( "git" ) ) ;
222+
223+ assert_eq ! ( modal. list. search_query( ) , "git" ) ;
224+ assert_eq ! ( modal. list. filtered_len( ) , 1 ) ;
225+ assert_eq ! (
226+ modal. selected_server( ) . map( |server| server. name. as_str( ) ) ,
227+ Some ( "github" )
228+ ) ;
229+ }
230+ }
Original file line number Diff line number Diff line change @@ -324,6 +324,16 @@ impl SelectionList {
324324 & self . search_query
325325 }
326326
327+ /// Append text to the current search query and update filtered items.
328+ pub fn append_search_text ( & mut self , text : & str ) {
329+ if text. is_empty ( ) {
330+ return ;
331+ }
332+
333+ self . search_query . push_str ( text) ;
334+ self . apply_filter ( ) ;
335+ }
336+
327337 /// Get the number of filtered items.
328338 pub fn filtered_len ( & self ) -> usize {
329339 self . filtered_indices . len ( )
You can’t perform that action at this time.
0 commit comments