From 8013686d17c13d9e3363ffa1ccd55f96cc39b2cb Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 3 Jul 2019 11:44:08 +0200 Subject: [PATCH] delete-or-exit: Only exit if the commandline is empty This exitted if the cursor was at the end of the line as well (i.e. if delete-char failed). That's a bit too eager. Also documentation, which should have already been included. --- sphinx_doc_src/cmds/bind.rst | 2 ++ src/reader.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sphinx_doc_src/cmds/bind.rst b/sphinx_doc_src/cmds/bind.rst index cb90f406f..4bb0aa821 100644 --- a/sphinx_doc_src/cmds/bind.rst +++ b/sphinx_doc_src/cmds/bind.rst @@ -102,6 +102,8 @@ The following special input functions are available: - ``delete-char``, delete one character to the right of the cursor +- ``delete-or-exit``, deletes one character to the right of the cursor or exits the shell if the commandline is empty. + - ``downcase-word``, make the current word lowercase - ``end-of-buffer``, moves to the end of the buffer, i.e. the end of the first line diff --git a/src/reader.cpp b/src/reader.cpp index 88baa3e60..6249a7a08 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -2682,7 +2682,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat if (el->position < el->size()) { update_buff_pos(el, el->position + 1); remove_backward(); - } else if (c == rl::delete_or_exit) { + } else if (c == rl::delete_or_exit && el->empty()) { reader_set_end_loop(true); } break;