@@ -512,14 +512,18 @@ impl IdeMenu {
512512 } ;
513513
514514 if use_ansi_coloring {
515- let match_len = self
516- . working_details
517- . shortest_base_string
518- . len ( )
519- . min ( string. len ( ) ) ;
515+ // strip quotes
516+ let is_quote = |c : char | "`'\" " . contains ( c) ;
517+ let shortest_base = & self . working_details . shortest_base_string ;
518+ let shortest_base = shortest_base
519+ . strip_prefix ( is_quote)
520+ . unwrap_or ( shortest_base) ;
521+ let match_len = shortest_base. len ( ) . min ( string. len ( ) ) ;
520522
521523 // Split string so the match text can be styled
522- let ( match_str, remaining_str) = string. split_at ( match_len) ;
524+ let skip_len = string. chars ( ) . take_while ( |c| is_quote ( * c) ) . count ( ) ;
525+ let ( match_str, remaining_str) =
526+ string. split_at ( ( match_len + skip_len) . min ( string. len ( ) ) ) ;
523527
524528 let suggestion_style_prefix = suggestion
525529 . style
@@ -1441,4 +1445,27 @@ mod tests {
14411445
14421446 menu. menu_string ( 500 , true ) ;
14431447 }
1448+
1449+ #[ test]
1450+ fn test_menu_create_value_string ( ) {
1451+ // https://github.com/nushell/nushell/issues/13951
1452+ let mut completer = FakeCompleter :: new ( & [ "おはよう" , "`おはよう(`" ] ) ;
1453+ let mut menu = IdeMenu :: default ( ) . with_name ( "testmenu" ) ;
1454+ menu. working_details = IdeMenuDetails {
1455+ cursor_col : 50 ,
1456+ menu_width : 50 ,
1457+ completion_width : 50 ,
1458+ description_width : 50 ,
1459+ description_is_right : true ,
1460+ space_left : 50 ,
1461+ space_right : 50 ,
1462+ description_offset : 50 ,
1463+ shortest_base_string : String :: new ( ) ,
1464+ } ;
1465+ let mut editor = Editor :: default ( ) ;
1466+
1467+ editor. set_buffer ( "おは" . to_string ( ) , UndoBehavior :: CreateUndoPoint ) ;
1468+ menu. update_values ( & mut editor, & mut completer) ;
1469+ assert ! ( menu. menu_string( 2 , true ) . contains( "`おは" ) ) ;
1470+ }
14441471}
0 commit comments