diff options
author | Jonathan Slenders <jonathan@slenders.be> | 2016-07-21 22:58:40 +0200 |
---|---|---|
committer | Jonathan Slenders <jonathan@slenders.be> | 2016-07-21 22:58:40 +0200 |
commit | c64a17306d643abef7b4d1626f5cf909aad0a98e (patch) | |
tree | 5ecb8af479bb7e8d60e74e09a011dbcac097ec4f | |
parent | be68caacffec4695379fd241903689e5e6731688 (diff) |
When Control-K has been pressed at the end of the line, delete the newline after the cursor.
-rw-r--r-- | prompt_toolkit/key_binding/bindings/named_commands.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/prompt_toolkit/key_binding/bindings/named_commands.py b/prompt_toolkit/key_binding/bindings/named_commands.py index 888e1b68..98e832ad 100644 --- a/prompt_toolkit/key_binding/bindings/named_commands.py +++ b/prompt_toolkit/key_binding/bindings/named_commands.py @@ -270,12 +270,19 @@ def capitalize_word(event): def kill_line(event): """ Kill the text from the cursor to the end of the line. + + If we are at the end of the line, this should remove the newline. + (That way, it is possible to delete multiple lines by executing this + command multiple times.) """ buff = event.current_buffer if event.arg < 0: deleted = buff.delete_before_cursor(count=-buff.document.get_start_of_line_position()) else: - deleted = buff.delete(count=buff.document.get_end_of_line_position()) + if buff.document.current_char == '\n': + deleted = buff.delete(1) + else: + deleted = buff.delete(count=buff.document.get_end_of_line_position()) event.cli.clipboard.set_text(deleted) |