Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Should be possible to manipulate (collapse, censor) "Undo" stack items #90

Open
mcclure opened this issue Nov 26, 2024 · 0 comments

Comments

@mcclure
Copy link

mcclure commented Nov 26, 2024

So, if you check out my vim compatibility patch

#89

and run with cargo run --example vim -- README.md

Because tui-textarea does not give good direct access to the lines stack, I implemented my new commands in terms of the verbs exposed on the TextArea object. However, this means if after doing some of my new commands you undo, the undo will take place in several steps.

For example, for the J command, in normal mode it works by moving the cursor to the end of the line (textarea.move_cursor(CursorMove::End);), deleting the newline (textarea.delete_line_by_end();), and inserting a space (textarea.insert_char(' ');). However, this creates two items on the undo stack: If you want to undo, you have to undo twice, once for the delete and once for the insert. If you do J in visual mode, it does each of these two for each line, so joining ten lines means you must undo 20 times to actually undo. This is a bad user experience, and not what a user would expect.

Feature request: I should be able to combine multiple verbs (function calls to textarea) into one undo item. Two ways this could work are:

  • "Checkpointing"; before making a block of changes, issue a textarea.begin_undo_item(), afterward issue a textarea.end_undo_item(), and everything in between the two counts as one undo.
  • "Merging"; have a undo_merge_last_items() (or an undo_merge_next_item()) which merges two items on the stack; when doing many combined commands (for example, my ten-line J) you just merge many times.

I don't know which approach would be most efficient with the TextArea implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant