Add undo#6570
Merged
Merged
Conversation
0eb9552 to
0d6a13a
Compare
ridiculousfish
approved these changes
Feb 7, 2020
Member
ridiculousfish
left a comment
There was a problem hiding this comment.
This is awesome!! The code is solid 💯.
Add the input function undo which is bound to `\c_` (control + / on some terminals). Redoing the most recent chain of undos is supported, redo is bound to `\e/` for now. Closes fish-shell#1367. This approach should not have the issues discussed in fish-shell#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.
Contributor
Author
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.Suggestion cannot be applied right now. Please check back later.
Add the readline function
undowhich is bound to\c_(control + / onsome terminals). Redoing the most recent chain of undos is supported,
redois 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)
uand\crare 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_lineandcycle_cursor_posbecause we can obtain those from the history.