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

Automatically selecting auto completion suggestion despite not pressing enter or tab key #357

Closed
lakshits11 opened this issue Jul 11, 2022 · 5 comments · Fixed by #358
Closed
Labels
bug Something isn't working

Comments

@lakshits11
Copy link

Please describe the problem.
For hints on what information is helpful, see: https://clangd.llvm.org/troubleshooting.html

After todays update to version 0.1.18, it automatically selects the auto completion suggestion.

image

For example if i write while and then when i open a curved bracket without clicking or selecting the while snippet suggestion, it automatically selects that snippet without my wish and finally it looks like this:
image

There are two brackets inside while loop, one is mine and other is snippet's.

Same problem is also occuring in if and also many other conditions/loops etc.

When I reverted back to older version, the problem disappeared.

Logs
Please attach the clangd log from the "Output" window if you can.
If possible, run with --log=verbose - note that the logs will include the contents of open files!

I[00:44:13.619] --> textDocument/clangd.fileStatus
I[00:44:13.619] --> textDocument/clangd.fileStatus
I[00:44:13.621] --> workspace/semanticTokens/refresh(37)
I[00:44:13.621] --> textDocument/clangd.fileStatus
I[00:44:13.621] --> textDocument/clangd.fileStatus
I[00:44:13.621] --> textDocument/clangd.fileStatus
I[00:44:13.621] <-- reply(37)

System information
Clangd version (from the log, or clangd --version):
image

clangd extension version: 0.1.18
Operating system: Manjaro XFCE

@lakshits11 lakshits11 added the bug Something isn't working label Jul 11, 2022
sam-mccall added a commit that referenced this issue Jul 11, 2022
This reverts commit eb61c51.

Unfortunately the languageclient upgrade causes completion problems e.g.
#357

Need to work out how to address these before rolling forward.
@jasonwzz
Copy link

I noticed something like this as well but I thought this is expected from editor.acceptSuggestionOnCommitCharacter being fixed with the newer version (#347). I turned acceptSuggestionOnCommitCharacter off to get back to what it was. Is my understanding incorrect that this is actually not expected or is this a different issue?

@sam-mccall
Copy link
Member

Yeah, there are a few intersecting pieces of behavior here:

Because it was broken for so long, we didn't understand all the interactions, and the result is a broken mess: you type whi(, maybe with no intention of triggering completion at all, and get while ((condition)) { }.
While each individual piece is working as (someone) intended, the result best seen as a bug.

The only piece we have control over is the set of commit characters, so we'll try and find a sensible fix in those terms.

sam-mccall added a commit to sam-mccall/vscode-clangd that referenced this issue Jul 12, 2022
The use of commit-characters in clangd had good intentions, but it has
terrible UX in practice in VSCode, as documented on the linked bug.

We didn't notice this until it was far too late: the commit characters
were added in clangd 12, but bugs in vscode-languageclient prevented
them from being noticed until languageclient-8.
(microsoft/vscode-languageserver-node#673)

At this point we can't go back and change the server behavior so we need
to override it on the client.

Fixes clangd#357
sam-mccall added a commit that referenced this issue Jul 12, 2022
The use of commit-characters in clangd had good intentions, but it has
terrible UX in practice in VSCode, as documented on the linked bug.

We didn't notice this until it was far too late: the commit characters
were added in clangd 12, but bugs in vscode-languageclient prevented
them from being noticed until languageclient-8.
(microsoft/vscode-languageserver-node#673)

At this point we can't go back and change the server behavior so we need
to override it on the client.

Fixes #357
@HighCommander4
Copy link
Contributor

HighCommander4 commented Jul 15, 2022

Doesn't the approach taken here take control away from users, in that previously if they didn't like this behaviour they could turn off editor.acceptSuggestionsOnCommitCharacter, but if they do like it (e.g. see #347), now there's no way to turn it back on?

@sam-mccall
Copy link
Member

Strictly: no, because this never worked! (except for ~1 day, with 0.1.19)

Relative to if we set the commit characters: yes, absolutely, and i think this is a problem.

However if the default behavior is extremely broken, that's a big problem. Exacerbated by:

  • many users won't explore the settings
  • it's not obvious what to change to fix this, symptoms are intuitive ("completion feels wrong") and it takes some investigation even to work out what you want

I might be wrong about this behavior being very broken - it seems jrieken likes it, there must be at least one other! @HighCommander4 did you manage to reproduce the behavior in vscode? I find it incredibly jarring, more than it looks like on paper.

@HighCommander4
Copy link
Contributor

@HighCommander4 did you manage to reproduce the behavior in vscode?

Yeah, you were right that the reason I wasn't seeing the auto-activation was due to editor.quickSuggestions.other: off, and the commit behaviour due to being on an older vscode-clangd than 0.1.18.

Having now installed 0.1.18 to see what it's like, I agree that interaction between the ( commit character and snippets is bad, and means that ( probably shouldn't be a commit character until vscode fixes that somehow (or at least, not a commit character when snippets are enabled?)

Some of the other commit characters seem fine, though, and some like ; and . in particular seem useful -- perhaps we could consider bringing back a more restricted set?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants