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

Reset mode when changing buffers #5072

Conversation

the-mikedavis
Copy link
Member

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

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.
@the-mikedavis the-mikedavis added C-bug Category: This is a bug S-waiting-on-review Status: Awaiting review from a maintainer. labels Dec 8, 2022
@@ -694,6 +694,7 @@ fn goto_buffer(editor: &mut Editor, direction: Direction) {

let id = *id;

normal_mode_impl(editor);
Copy link
Member

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?

Copy link
Member Author

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

@pascalkuthe
Copy link
Member

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).
@kirawi kirawi added the A-helix-term Area: Helix term improvements label Dec 9, 2022
@archseer archseer merged commit cdc54f5 into helix-editor:master Dec 11, 2022
@the-mikedavis the-mikedavis deleted the md-goto-buffer-switch-to-normal-mode branch December 11, 2022 17:01
freqmod pushed a commit to freqmod/helix that referenced this pull request Feb 8, 2023
* 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changeset panic when swapping between buffers in insertion mode
4 participants