@@ -147,10 +147,46 @@ def test_ctrl_a_move_to_start_with_echo_char(self):
147147 # Ctrl+A should move cursor to start
148148 self .check_raw_input ('end\x01 start\n ' , 'startend' )
149149
150+ def test_ctrl_a_cursor_position (self ):
151+ # After Ctrl+A, cursor is at position 0.
152+ # Refresh writes backspaces to move cursor from end to start.
153+ output = self .check_raw_input ('abc\x01 \n ' , 'abc' )
154+ self .assertEndsWith (output , 'Password: ***\x08 \x08 \x08 ' )
155+
156+ def test_ctrl_a_on_empty (self ):
157+ # Ctrl+A on empty line should be a no-op
158+ self .check_raw_input ('\x01 hello\n ' , 'hello' )
159+
160+ def test_ctrl_a_already_at_start (self ):
161+ # Double Ctrl+A should be same as single Ctrl+A
162+ self .check_raw_input ('abc\x01 \x01 start\n ' , 'startabc' )
163+
164+ def test_ctrl_a_then_backspace (self ):
165+ # Backspace after Ctrl+A should do nothing (cursor at 0)
166+ self .check_raw_input ('abc\x01 \x7f \n ' , 'abc' )
167+
150168 def test_ctrl_e_move_to_end_with_echo_char (self ):
151169 # Ctrl+E should move cursor to end
152170 self .check_raw_input ('start\x01 X\x05 end\n ' , 'Xstartend' )
153171
172+ def test_ctrl_e_cursor_position (self ):
173+ # After Ctrl+A then Ctrl+E, cursor is back at end.
174+ # Refresh has no backspaces since cursor is at end.
175+ output = self .check_raw_input ('abc\x01 \x05 \n ' , 'abc' )
176+ self .assertEndsWith (output , 'Password: ***' )
177+
178+ def test_ctrl_e_on_empty (self ):
179+ # Ctrl+E on empty line should be a no-op
180+ self .check_raw_input ('\x05 hello\n ' , 'hello' )
181+
182+ def test_ctrl_e_already_at_end (self ):
183+ # Ctrl+E when already at end should be a no-op
184+ self .check_raw_input ('abc\x05 more\n ' , 'abcmore' )
185+
186+ def test_ctrl_a_then_ctrl_e (self ):
187+ # Ctrl+A then Ctrl+E should return cursor to end, typing appends
188+ self .check_raw_input ('abc\x01 \x05 def\n ' , 'abcdef' )
189+
154190 def test_ctrl_k_kill_forward_with_echo_char (self ):
155191 # Ctrl+K should kill from cursor to end
156192 self .check_raw_input ('delete\x01 \x0b keep\n ' , 'keep' )
0 commit comments