File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
prompt_toolkit/key_binding/bindings Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ def _(event):
198198 """
199199 buffer = event .current_buffer
200200
201- if buffer .document .current_char == ' \n ' :
201+ if buffer .document .is_cursor_at_the_end_of_line :
202202 buffer .cursor_position += buffer .document .get_start_of_line_position (after_whitespace = False )
203203 else :
204204 buffer .cursor_position += buffer .document .get_end_of_line_position ()
Original file line number Diff line number Diff line change @@ -245,6 +245,21 @@ def test_emacs_other_bindings():
245245 assert result .text == 'hello X'
246246
247247
248+ def test_controlx_controlx ():
249+ # At the end: go to the start of the line.
250+ result , cli = _feed_cli_with_input ('hello world\x18 \x18 X\n ' )
251+ assert result .text == 'Xhello world'
252+ assert result .cursor_position == 1
253+
254+ # At the start: go to the end of the line.
255+ result , cli = _feed_cli_with_input ('hello world\x01 \x18 \x18 X\n ' )
256+ assert result .text == 'hello worldX'
257+
258+ # Left, Left Control-X Control-X: go to the end of the line.
259+ result , cli = _feed_cli_with_input ('hello world\x1b [D\x1b [D\x18 \x18 X\n ' )
260+ assert result .text == 'hello worldX'
261+
262+
248263def test_emacs_history_bindings ():
249264 # Adding a new item to the history.
250265 history = _history ()
You can’t perform that action at this time.
0 commit comments