@@ -607,6 +607,30 @@ def test_global_namespace_completion(self):
607
607
output = multiline_input (reader , namespace )
608
608
self .assertEqual (output , "python" )
609
609
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
+
610
634
611
635
@patch ("_pyrepl.curses.tigetstr" , lambda x : b"" )
612
636
class TestUnivEventQueue (TestCase ):
@@ -1001,6 +1025,5 @@ def test_up_arrow_after_ctrl_r(self):
1001
1025
reader , _ = handle_all_events (events )
1002
1026
self .assert_screen_equals (reader , "" )
1003
1027
1004
-
1005
1028
if __name__ == '__main__' :
1006
1029
unittest .main ()
0 commit comments