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

Autocompletion error: words do not get replaced correctly (JavaScript) #2580

Closed
aral opened this issue May 27, 2022 · 4 comments
Closed

Autocompletion error: words do not get replaced correctly (JavaScript) #2580

aral opened this issue May 27, 2022 · 4 comments
Labels
A-language-server Area: Language server client C-bug Category: This is a bug

Comments

@aral
Copy link
Contributor

aral commented May 27, 2022

Summary

Just ran into an odd autocompletion error in a JavaScript file.

Reproduction Steps

The steps:

Selecting word to change:

Screenshot from 2022-05-27 10-34-48

Starting to change it:

Screenshot from 2022-05-27 10-34-55

Getting autocompletion:

Screenshot from 2022-05-27 10-35-04

Tabbing through the options, all is well with the first few until I get to:

Screenshot from 2022-05-27 10-35-19

Notice that the original fi is not replaced with the completion. Rather the completion is erroneously added to it.

Since this is a field, the beginning of the completion string – which includes the .this reference – differs from beginning of the variable name as I started writing it. I’m assuming the string replacement logic in Helix has to be updated to take this case into consideration.

Finally, the corruption remains after using enter to finalise the completion:

Screenshot from 2022-05-27 10-35-24

Helix log

No entries in the log from around this time.

Platform

Linux (Fedora Silverblue 36)

Terminal Emulator

GNOME Console

Helix Version

helix 22.05-dev (8df8ff2)

@aral aral added the C-bug Category: This is a bug label May 27, 2022
@aral aral changed the title Autocompletion error (JavaScript) Autocompletion error with fields; when “this.” is added (JavaScript) May 27, 2022
@aral aral changed the title Autocompletion error with fields; when “this.” is added (JavaScript) Autocompletion error: words do not get replaced correctly (JavaScript) May 27, 2022
@aral
Copy link
Contributor Author

aral commented May 27, 2022

I just realised that is a more generic issue where the autocompletion replacement is corrupted unless you start the autocompletion at the very start of the word.

I’m in the middle of a word:

Screenshot from 2022-05-27 10-50-58

I enter insert mode and I get autocompletions:

Screenshot from 2022-05-27 10-51-03

I select an autocompletion:

Screenshot from 2022-05-27 10-51-07

Instead of replacing addFile with addEventListener, the completion term is inserted at the cursor position, resulting in the corrupted addEventListenerFile completion.

Finally, as before, the corruption remains when you finalise the completion:

Screenshot from 2022-05-27 10-51-12

@aral
Copy link
Contributor Author

aral commented May 27, 2022

Related #2027: this also explains the odd corruptions I see when I forget and move around in insert mode. Because of this, I’ve basically started using insert mode only for single lines whenever possible and keep coming in and out of normal mode even when initially writing a contiguous piece of code as at least then I get granular undo to quickly fix autocomplete corruption errors should I forget an navigate in insert mode again.

I do feel this needs a better solution.

@the-mikedavis
Copy link
Member

This may be fixed by #1819

@pascalkuthe
Copy link
Member

I am pretty sure this was mostly fixed by recent improvements to completion handling (although your second comment is not a but just how completions work, for servers that support it completions replace can now be configured but not all do).

I think the remaining cases are covered by #2027 so I am closing this issue in favor of that one

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

No branches or pull requests

4 participants