accept-autosuggestion to return false if there was no autosuggestion to accept

Example usage:

    bind ctrl-space accept-autosuggestion and execute

Closes #10608
This commit is contained in:
diniamo 2024-07-09 02:16:21 +02:00 committed by Johannes Altmanninger
parent cd3da62d24
commit 052e764f29
3 changed files with 4 additions and 1 deletions

View File

@ -180,6 +180,7 @@ New or improved bindings
- New special input functions:
- ``forward-char-passive`` and ``backward-char-passive`` are like their non-passive variants but do not accept autosuggestions or move focus in the completion pager (:issue:`10398`).
- ``forward-token``, ``backward-token``, ``kill-token``, and ``backward-kill-token`` are similar to the ``*-bigword`` variants but for the whole argument token which includes escaped spaces (:issue:`2014`).
- The ``accept-autosuggestion`` special input function now returns false when there was nothing to accept.
- Vi mode has seen some improvements but continues to suffer from the lack of people working on it.
- Insert-mode :kbd:`ctrl-n` accepts autosuggestions (:issue:`10339`).
- Outside insert mode, the cursor will no longer be placed beyond the last character on the commandline.

View File

@ -112,7 +112,7 @@ The following special input functions are available:
only execute the next function if the previous succeeded (note: only some functions report success)
``accept-autosuggestion``
accept the current autosuggestion
accept the current autosuggestion. Returns false when there was nothing to accept.
``backward-char``
move one character to the left.

View File

@ -2984,7 +2984,9 @@ impl<'a> Reader<'a> {
self.input_data.function_set_status(success);
}
rl::AcceptAutosuggestion => {
let success = !self.autosuggestion.is_empty();
self.accept_autosuggestion(true, false, MoveWordStyle::Punctuation);
self.input_data.function_set_status(success);
}
rl::TransposeChars => {
let (elt, el) = self.active_edit_line();