@@ -607,6 +607,30 @@ def test_global_namespace_completion(self):
607607 output = multiline_input (reader , namespace )
608608 self .assertEqual (output , "python" )
609609
610+ def test_updown_arrow_with_completion_menu (self ):
611+ """Up arrow in the middle of unfinished tab completion when the menu is displayed
612+ should work and trigger going back in history. Down arrow should subsequently
613+ get us back to the incomplete command."""
614+ code = "import os\n os.\t \t "
615+ namespace = {"os" : os }
616+
617+ events = itertools .chain (
618+ code_to_events (code ),
619+ [
620+ Event (evt = 'key' , data = 'up' , raw = bytearray (b'\x1b OA' )),
621+ Event (evt = "key" , data = "down" , raw = bytearray (b"\x1b OB" )),
622+ ],
623+ code_to_events ("\n " )
624+ )
625+ reader = self .prepare_reader (events , namespace = namespace )
626+ output = multiline_input (reader , namespace )
627+ # This is the first line, nothing to see here
628+ self .assertEqual (output , "import os" )
629+ # This is the second line. We pressed up and down arrows
630+ # so we should end up where we were when we initiated tab completion.
631+ output = multiline_input (reader , namespace )
632+ self .assertEqual (output , "os." )
633+
610634
611635@patch ("_pyrepl.curses.tigetstr" , lambda x : b"" )
612636class TestUnivEventQueue (TestCase ):
@@ -1001,6 +1025,5 @@ def test_up_arrow_after_ctrl_r(self):
10011025 reader , _ = handle_all_events (events )
10021026 self .assert_screen_equals (reader , "" )
10031027
1004-
10051028if __name__ == '__main__' :
10061029 unittest .main ()
0 commit comments