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

Only suggest automatic autocompletion after edit #6910

Closed
wants to merge 3 commits into from

Conversation

freqmod
Copy link

@freqmod freqmod commented Apr 29, 2023

When i move around in the document in insert mode i sometimes contemplate and wait a bit before continuing moving around. In this case i often get caught in an autocomplete dialogue and ends up changing the document without intention. I think it would be better to limit autocomplete to when a user has just changed the document, and not moved around.

I made a patch which made moving around with autocomplete enabled much more intuitive for me.
I guess it could be made an option if you don't want to change the default helix behaviour though.

@the-mikedavis
Copy link
Member

This is mostly the same as #5803. Tracking this with a bool toggled on the doc or view or editor seems ad-hoc to me, I'd like to find a more robust way to know when to trigger completion in insert mode. Maybe the implementation for #1596 would be relevant for this.

Also I think there may be some missing changes for this PR? register_insert_mode_movement isn't called so once move_since_changed is set to false it's never true again

@pascalkuthe
Copy link
Member

pascalkuthe commented Apr 30, 2023

The way vscode handles this is by requesting completions on every trigger character.

Trigger characters are those send by the LSP and any word character (\w). From the spec:

The additional characters, beyond the defaults provided by the client (typically [a-zA-Z]), that should automatically trigger a completion request

If you read the spec carefully its quite clear that completion requests are mostly only intended to be send for trigger chars or manually (pressing c-x). There is not "timeout" completion trigger. These completion triggers are of course debounced. By setting the debounce timer to something very low (like 20ms) we would attain vscode-like behavior (without lots of wasted processing/werid behavior that a low idle timeout causes) and by setting the debounce timer to something higher (500ms) we would retain the current default behaviour (only open completions after a while).

This also solves some unfortunate interactions right now that are caused by the fact that the idle timeout was originally added for completion but is now used by lots of things (inlay hints for example). For many of these applications I want to move to a similar similar scheme that I described for completions (custom debounced triggers). For that I am working on a general event/hook system for helix. Otherwise, all these custom hooks sprinkled throughout the codebase would cause too much clutter.

@freqmod
Copy link
Author

freqmod commented May 1, 2023

I am sorry, it seems like a line in set_selection was lost when i ported it from my own branch which support selection undo.

In any case i have fixed it now, even though it sounds like you want to do this in another way anyhow.

I am using helix as my daily editor at work now, which is great, but without this functionality, and 2-3 similar other patches i would not be able to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants