summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Slenders <jonathan@slenders.be>2016-07-21 23:06:20 +0200
committerJonathan Slenders <jonathan@slenders.be>2016-07-21 23:06:20 +0200
commit41e1152367ba45e293006f20aa8656a670549ce3 (patch)
tree44f12e7b834c8072670413c1d7082725d7116e0a
parentc64a17306d643abef7b4d1626f5cf909aad0a98e (diff)
Pressing Control-U at the start of the line should delete the newline.
-rw-r--r--prompt_toolkit/key_binding/bindings/named_commands.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/prompt_toolkit/key_binding/bindings/named_commands.py b/prompt_toolkit/key_binding/bindings/named_commands.py
index 98e832ad..2f587cdb 100644
--- a/prompt_toolkit/key_binding/bindings/named_commands.py
+++ b/prompt_toolkit/key_binding/bindings/named_commands.py
@@ -349,8 +349,13 @@ def unix_line_discard(event):
Kill backward from the cursor to the beginning of the current line.
"""
buff = event.current_buffer
- deleted = buff.delete_before_cursor(count=-buff.document.get_start_of_line_position())
- event.cli.clipboard.set_text(deleted)
+
+ if buff.document.cursor_position_col == 0 and buff.document.cursor_position > 0:
+ buff.delete_before_cursor(count=1)
+ else:
+ deleted = buff.delete_before_cursor(count=-buff.document.get_start_of_line_position())
+ event.cli.clipboard.set_text(deleted)
+
@register('yank')
@register('yank-pop')