reader: Return true if suppress-autosuggestion suppressed

This allows

bind -k backspace suppress-autosuggestion or backward-delete-char

To remove the suggestion on the first press and then delete
chars.

Note: This requires that we then don't reenable suggestions
immediately afterwards. Currently we don't after deletion.

Fixes #1419.
This commit is contained in:
Fabian Homborg 2020-09-26 10:07:53 +02:00
parent 537b3f6cb1
commit 06f6436943
2 changed files with 4 additions and 1 deletions

View file

@ -174,7 +174,7 @@ The following special input functions are available:
- ``self-insert-notfirst``, inserts the matching sequence into the command line, unless the cursor is at the beginning
- ``suppress-autosuggestion``, remove the current autosuggestion
- ``suppress-autosuggestion``, remove the current autosuggestion. Returns true if there was a suggestion to remove.
- ``swap-selection-start-stop``, go to the other end of the highlighted text without changing the selection

View file

@ -3298,7 +3298,10 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
}
case rl::suppress_autosuggestion: {
suppress_autosuggestion = true;
bool success = !autosuggestion.empty();
autosuggestion.clear();
// Return true if we had a suggestion to clear.
inputter.function_set_status(success);
break;
}
case rl::accept_autosuggestion: {