@@ -518,7 +518,7 @@ pub fn run(
518518 cleanup ( & mut out, & state) ?;
519519 return Ok ( super :: SelectResult :: Cancelled ) ;
520520 }
521- KeyCode :: Char ( 'u' ) if modifiers. contains ( KeyModifiers :: CONTROL ) => {
521+ KeyCode :: Char ( 'u' ) if modifiers == KeyModifiers :: CONTROL => {
522522 state. query . clear ( ) ;
523523 state. refilter ( ) ;
524524 }
@@ -536,7 +536,7 @@ pub fn run(
536536 KeyCode :: Down => {
537537 state. move_down ( ) ;
538538 }
539- KeyCode :: Char ( c) if modifiers . is_empty ( ) || modifiers == KeyModifiers :: SHIFT => {
539+ KeyCode :: Char ( c) if accepts_search_character ( modifiers) => {
540540 state. query . push ( c) ;
541541 state. refilter ( ) ;
542542 }
@@ -554,6 +554,12 @@ pub fn run(
554554 }
555555}
556556
557+ fn accepts_search_character ( modifiers : KeyModifiers ) -> bool {
558+ // Windows reports AltGr as Ctrl+Alt while preserving the printable character.
559+ let modifiers = modifiers. difference ( KeyModifiers :: SHIFT ) ;
560+ modifiers. is_empty ( ) || modifiers == ( KeyModifiers :: CONTROL | KeyModifiers :: ALT )
561+ }
562+
557563/// Clear the widget output and restore cursor.
558564fn cleanup ( stdout : & mut impl Write , state : & State < ' _ > ) -> anyhow:: Result < ( ) > {
559565 if state. rendered_lines > 0 {
@@ -676,6 +682,14 @@ mod tests {
676682 strip_ansi ( & String :: from_utf8 ( buf) . unwrap ( ) )
677683 }
678684
685+ #[ test]
686+ fn search_character_modifiers_preserve_alt_gr_input ( ) {
687+ assert ! ( accepts_search_character( KeyModifiers :: CONTROL | KeyModifiers :: ALT ) ) ;
688+ assert ! ( accepts_search_character(
689+ KeyModifiers :: CONTROL | KeyModifiers :: ALT | KeyModifiers :: SHIFT
690+ ) ) ;
691+ }
692+
679693 #[ test]
680694 fn truncates_long_description ( ) {
681695 let items = make_items ( & [ ( "build" , "a really long command that exceeds the width limit" ) ] ) ;
0 commit comments