-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Reset mode when changing buffers #5072
Reset mode when changing buffers #5072
Conversation
This is similar to the change in e4c9d40: reset the editor to normal mode when changing buffers. Usually the editor is already in normal mode but it's possible to setup insert-mode keybindings that change buffers.
helix-term/src/commands.rs
Outdated
@@ -694,6 +694,7 @@ fn goto_buffer(editor: &mut Editor, direction: Direction) { | |||
|
|||
let id = *id; | |||
|
|||
normal_mode_impl(editor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it makes more sense to move this into editor.switch
instead of adding this only here? I imagine the bug could appear for other commands aswell. editor.switch
is called many times and it seems like a huge footgut for it to cause crahses it the editor is not in normal mode. I think this bug could already be produced by other commands if you created a custom insert mode binding for them. I can't think of a situation where this wouldn't want to be a normal mode after a switch.
This will require moving normal_mode_impl
to helix-view
but that should be okay since the function is fairly small.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good call. I think we currently miss some steps when switching modes in Editor::focus
that would be resolved by that change as well
Awesome that you found this so quickly, you are really on a roll recently ironing out panics 👍 |
This should be called internally in the Editor when changing documents (Editor::switch) or changing focuses (Editor::focus).
* Reset mode when changing buffers This is similar to the change in e4c9d40: reset the editor to normal mode when changing buffers. Usually the editor is already in normal mode but it's possible to setup insert-mode keybindings that change buffers. * Move normal mode entering code to Editor This should be called internally in the Editor when changing documents (Editor::switch) or changing focuses (Editor::focus).
This is similar to the change in e4c9d40: reset the editor to normal mode when changing buffers. Usually the editor is already in normal mode but it's possible to setup insert-mode keybindings that change buffers.
Fixes #5058