File tree 2 files changed +16
-1
lines changed
prompt_toolkit/key_binding/bindings
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ def _(event):
198
198
"""
199
199
buffer = event .current_buffer
200
200
201
- if buffer .document .current_char == ' \n ' :
201
+ if buffer .document .is_cursor_at_the_end_of_line :
202
202
buffer .cursor_position += buffer .document .get_start_of_line_position (after_whitespace = False )
203
203
else :
204
204
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():
245
245
assert result .text == 'hello X'
246
246
247
247
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
+
248
263
def test_emacs_history_bindings ():
249
264
# Adding a new item to the history.
250
265
history = _history ()
You can’t perform that action at this time.
0 commit comments