Skip to content
New issue

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

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

Already on GitHub? # to your account

Make tab and shift-tab the only way to navigate autocompletion drop downs or make arrow keys exit insert mode to avoid code corruption issues #2581

Closed
aral opened this issue May 27, 2022 · 1 comment · Fixed by #8021
Labels
A-keymap Area: Keymap and keybindings C-enhancement Category: Improvements

Comments

@aral
Copy link
Contributor

aral commented May 27, 2022

If you move between lines using the arrow keys in insert mode, you can end up with code corruption (#2580) due to LSP autocompletion kicking in (#2027)

The easiest way to avoid this problem would be to limit the keybindings for navigating the autocompletion drop-down to tab and shifttab. In other words, to disallow the use of the up and down arrows on the autocompletion drop-downs.

The other solution

The only other way I can see of addressing this problem is to make it so that Helix automatically enters normal mode when the person uses the up or down arrow keys in insert mode.

Given save points are only registered at the end of an insert session, this might actually be a safer mode of operation.

@aral aral added the C-enhancement Category: Improvements label May 27, 2022
@aral aral changed the title Make tab and shift-tab the only way to navigate autocompletion drop downs to avoid code corruption issues in insert mode Make tab and shift-tab the only way to navigate autocompletion drop downs or make arrow keys exit insert mode to avoid code corruption issues in insert mode May 27, 2022
@aral aral changed the title Make tab and shift-tab the only way to navigate autocompletion drop downs or make arrow keys exit insert mode to avoid code corruption issues in insert mode Make tab and shift-tab the only way to navigate autocompletion drop downs or make arrow keys exit insert mode to avoid code corruption issues May 27, 2022
@the-mikedavis
Copy link
Member

You can disable the arrow keys in insert mode so they do nothing:

[keys.insert]
right = "no_op"
left = "no_op"
up = "no_op"
down = "no_op"

Or to switch into normal mode:

[keys.insert]
right = "normal_mode"
left = "normal_mode"
up = "normal_mode"
down = "normal_mode"

Though rebinding these doesn't affect their behavior in the completion menu.

I would be in favor of removing up/down keys from the completion menu's keymap. I think the keymap could do with fewer arrow-key bindings in general. C-n and C-p are also available so it wouldn't be only tab and shift+tab.

Having the default keymap automatically enter normal mode on arrow key presses could be a good way to train people to not use arrow keys in insert mode but it would be unexpected behavior I think. IIRC even vim leaves those keybindings for motion.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-keymap Area: Keymap and keybindings C-enhancement Category: Improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants