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

autocomplete triggers in insert mode #1381

Closed
adsick opened this issue Dec 26, 2021 · 7 comments
Closed

autocomplete triggers in insert mode #1381

adsick opened this issue Dec 26, 2021 · 7 comments
Labels
C-bug Category: This is a bug

Comments

@adsick
Copy link

adsick commented Dec 26, 2021

Oftentimes autocompletion triggers in the middle of a token and starts changing .methods() which is not desired as I'm just navigating the file in insert mode.

@adsick adsick added the C-bug Category: This is a bug label Dec 26, 2021
@dead10ck
Copy link
Member

Wait, are you saying you're just moving around with the arrow keys in insert mode, and it randomly decides to insert parens? Could you provide step by step instructions to reproduce this behavior?

@adsick
Copy link
Author

adsick commented Dec 26, 2021

are you saying you're just moving around with the arrow keys in insert mode

Yes.
I've figured out how to reproduce it:
for example take helix-term/src/main.rs:44:18
switch to append/insert mode
now move your cursor to the letter i just after the letter x as on the screenshot
image
if your minimal number of symbols to trigger autocompletion is 2 or less you will see it appearing which is extremely annoying in case you move vertically from line to line - you might accidentally change a method this way.

Looks like autocompletion triggers in case there are completions for symbols that are LEFT to the cursor (ignoring the fact that there is stuff RIGHT to it)
I hope the problem is clear, ask if it is not

@dead10ck
Copy link
Member

dead10ck commented Dec 26, 2021

Ahh, I see; this is just the auto complete being automatically triggered because you're resting the cursor in insert mode. Typically, as a modal editor, the workflow is designed around being in normal mode for navigation and switching to insert mode only to insert text. I'd encourage you to try this kind of workflow to get the most out of the modal editing paradigm.

With that said, there are a few config options you could try. auto-completion = false will disable the automatic pop-up, meaning to auto complete, you must explicitly hit Ctrl-x. Setting idle-timeout to a bigger value might also help.

As for completing even though there is text to the right, I think this is desired for cases like if you have a chain of method calls and you want to insert another, e.g. foo|.bar().baz() -> foo.quu|.bar().baz() and you want it to auto complete quux.

@kirawi
Copy link
Member

kirawi commented May 26, 2022

Closing as the above comment offers a solution.

@kendfss
Copy link

kendfss commented Jan 16, 2023

@dead10ck

this is just the auto complete being automatically triggered because you're resting the cursor in insert mode.

Yes, but the issue is that you cannot ignore auto-completion because the vertical movement keys are double-linked and you can't esc while the completions window is open without leaving insert mode.

As for completing even though there is text to the right, I think this is desired for cases like if you have a chain of method calls and you want to insert another, e.g. foo|.bar().baz() -> foo.quu|.bar().baz() and you want it to auto complete quux.

If that's the case then each language should, assuming they don't already, have an "expression-separators" list of strings and the sequence of characters following the cursor position must be prefixed by one of the elements, or be empty, in order to trigger auto-complete.

@brokenthorn
Copy link

meaning to auto complete, you must explicitly hit Ctrl-x

My god! I was looking for this information for 2 days, then I hit this "bug" and found the information where I least expected it! Helix needs to make this information easier to discover! 😄

Thanks!

@kirawi
Copy link
Member

kirawi commented Sep 18, 2023

This is in the docs: https://docs.helix-editor.com/keymap.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

5 participants