You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 doJ
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:
textarea.begin_undo_item()
, afterward issue atextarea.end_undo_item()
, and everything in between the two counts as one undo.undo_merge_last_items()
(or anundo_merge_next_item()
) which merges two items on the stack; when doing many combined commands (for example, my ten-lineJ
) you just merge many times.I don't know which approach would be most efficient with the TextArea implementation.
The text was updated successfully, but these errors were encountered: