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

Moving around in insert mode triggers LSP completions; it shouldn’t #2027

Closed
aral opened this issue Apr 8, 2022 · 7 comments · Fixed by #8021
Closed

Moving around in insert mode triggers LSP completions; it shouldn’t #2027

aral opened this issue Apr 8, 2022 · 7 comments · Fixed by #8021
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@aral
Copy link
Contributor

aral commented Apr 8, 2022

Summary

LSP completions should only be triggered while typing, not when moving around in LSP mode. Otherwise, it is very easy to corrupt code when using the up/down arrows to move between lines.

Reproduction Steps

For easier reproduction, set idle-timeout to 0 in your config.toml:

[editor]
idle-timeout = 0

Then, with the following basic JS example:

// Hello, World!
console.log('Hello, world')
  1. Go to line 2 (g2g)
  2. Enter insert mode (i)
  3. Press the right-arrow key three times then press the up-arrow key to get to the comment on line 1.

What should happen

The completion dialogue should not show and you should find yourself on line 1. The code on line 2 should remain unchanged.

What actually happens

The completion dialog shows and pressing the up arrow inserts the continue completion in the middle of the console keyword so you end up with:

// Hello, World!
continuensole.log('Hello, world')

Helix log

n/a

Platform

Linux (elementary OS 6; based on Ubuntu)

Terminal Emulator

io.elementary.t

Helix Version

helix 22.05-dev (2d4f94e)

@aral aral added the C-bug Category: This is a bug label Apr 8, 2022
@sudormrfbin
Copy link
Member

Previous discussion: #1381.

@aral
Copy link
Contributor Author

aral commented May 27, 2022

Given #2580 if this cannot be fixed natively within the design of Helix, perhaps the thing to do is to concede that insert mode only works on a single line and to force the editor to exit into normal mode whenever the person navigates to a different line using the up/down arrow keys.

While this will require people to constantly go back and forth between insert and normal mode, this does appear to be the expectation from what I’ve been reading from the responses and by making it automatic, Helix would at least avoid the code corruptions that can result from moving between lines using the arrow keys in insert mode.

The other way to avoid the corruptions would be to make tab and shift-tab be the only ways to navigate the autocompletion drop downs. Come to think of it, this might be the better solution.

@archseer
Copy link
Member

archseer commented Oct 12, 2022

You shouldn't set idle-timeout to 0: idle-timeout is used in other areas than just autocompletion, i.e. a85e386

Setting it to 0 isn't recommended since you'll keep re-triggering various behaviors immediately and waste a lot of CPU cycles (depending on event ordering it could be after every single keypress). Even setting it to something as low as 2 or 5 would be better.

This same issue is present in kakoune. They offer an insert mode keybind: <c-o>: disable automatic completion for this insert session which could be used to disable completion before moving around.

@p1gp1g
Copy link
Contributor

p1gp1g commented Oct 12, 2022

@aral : What do you think of the solution suggested in #4144 : a setting to ignore arrows to enter in the pop ups. So you can do tab then arrows to pick a suggestion (or only tabs)?

I am asking because I have supposed you had the same issue and this may help. But I may have wrongly supposed :)

@nuke-web3
Copy link
Contributor

Helix is a modal editor. You are not supposed to move in insert mode. Normal mode is intended for movement.

Although "correct" that doesn't help fix a common issue that many run into. If this is the stance of Helix, I think the arrow keys should be disabled for movement in insert mode. Thus forcing you to use it "right".

A better solution would be to change the insert LSP suggestions to be selected by something other than arrow keys or perhaps via C+<arrow> or A+<arrows> so insert navigation is possible without this footgun IMHO.

@kirawi
Copy link
Member

kirawi commented Sep 12, 2023

If this is the stance of Helix, I think the arrow keys should be disabled for movement in insert mode.

It was removed (#3671), but there were a lot of people who expected at least a basic level of movement so we compromised (#3915) following a poll at #3865

@kirawi
Copy link
Member

kirawi commented Sep 12, 2023

Also see the linked PR that will close this: #8021

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants