Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Add the readline function
undo
which is bound to\c_
(control + / onsome terminals). Redoing the most recent chain of undos is supported,
redo
is bound to\e/
for now.Closes #1367.
This approach should not have the issues discussed in #5897.
Every single modification to the commandline can be undone individually,
except for adjacent single-character inserts, which are coalesced,
so they can be reverted with a single undo. Coalescing is not done for
space characters, so each word can be undone separately.
When moving between history search entries, only the current history
search entry is reachable via the undo history. This allows to go back
to the original search string with a single undo, or by pressing the
escape key.
Similarly, when moving between pager entries, only the most recent
selection in the pager can be undone.
TODO: (I'm not sure about the first three)
\e/
does not seem to work on xterm(it is tempting to add emacs-style redo but that would probably be less popular)
u
and\cr
are taken)These areas should be mostly alright based on what I tried but there may be room for improvement:
I think this also allows us to get rid of
cycle_command_line
andcycle_cursor_pos
because we can obtain those from the history.