Add a
entering Insert mode with appending cursor instead #2
Loading…
Reference in New Issue
No description provided.
Delete Branch "emma/breed:append"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
You don't need a new mode for append.
@ -189,1 +192,4 @@
}
KeyCode::Char('a') => {
self.move_cursor(Direction::Right);
self.mode = Mode::Append;
None of the new
Mode::Append
code is necessary if you just setself.mode
toMode::Insert
instead.Okay, then what is the best way to pass the fact that we pressed
a
instead ofi
inon_normal_event()
toon_insert_event()
so i can tell it to move the cursor back when it re-entersMode::Normal
?We can give the
Mode::Insert
variant some data. Let's make a new struct namedInsertState
which contains a boolean field namedappend
, then add it toMode::Insert
. Then,on_insert_event()
can be modified to take a mutable reference toInsertState
as an argument.on_event()
will match that innerInsertState
data onInsert
then pass it toon_insert_data()
. Exiting insert mode inon_insert_event()
can check the flag to see if it should move the cursor back or not.