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

Fix autocompletion leading to duplicated symbols and tokens #527

Merged
merged 4 commits into from
Jul 25, 2022
Merged

Fix autocompletion leading to duplicated symbols and tokens #527

merged 4 commits into from
Jul 25, 2022

Conversation

machitgarha
Copy link
Collaborator

This should close #487.

Effectively, this fixes a bunch of bugs causing duplicated symbols
or tokens when choosing an auto-completion item from the list. For
instance, it fixes use statements, @sth in docblocks, fully-
qualified names, etc.
@machitgarha machitgarha marked this pull request as ready for review July 18, 2022 15:54
@machitgarha
Copy link
Collaborator Author

machitgarha commented Jul 18, 2022

To fix variables producing two dollars in autocompletion, we should change Serenata instead. atom-languageclient excludes trigger characters from being replaced (i.e. $ is not included in replacementPrefix in this case). So, we should send a TextEdit.newText from Serenata not including the dollar sign itself.

@Gert-dev, what's your opinion?

@machitgarha machitgarha changed the title [WIP] Fix autocompletion leading to duplicated symbols and tokens Fix autocompletion leading to duplicated symbols and tokens Jul 18, 2022
@Gert-dev
Copy link
Owner

tl;dr: IIRC the textEdit property and its range should take care of this so the client does not need to make assumptions. The old way of inserting using a special separator character list is only still present for clients not supporting that later revision of the protocol.

IIRC, though it's been a while, the Serenata server should already be sending an actual text edit with a range that includes the dollar sign when it needs to be replaced in the textEdit property, and the client should be adhering to that range.

From what I remember the list of special characters to treat differently during completion were the initial way for servers to say "insert this text at the current position", and clients needed to be smart and decide what parts of the word needed to be replaced when inserting the completion provided by the server. This resulted in problems with special characters such as dollar signs as in most languages these are not part of identifiers like PHP, and making a good single decision for all programming languages and their different servers isn't easy.

In a later revision of the protocol, they introduced the textEdit property on completions with a range to fix this, so the server can say exactly what characters need to be replaced.

@machitgarha
Copy link
Collaborator Author

So you think we should report an issue in atom-languageclient?

@machitgarha
Copy link
Collaborator Author

machitgarha commented Jul 21, 2022

So this is it; this PR is ready. It contains a workaround for variables, until the upstream PR is merged.

@machitgarha
Copy link
Collaborator Author

It is not ready yet. The update to 1.16 of atom-languageclient caused a regression: when trying to use a class, and the auto-insertion of the use statements happens on top of the file, it places two duplicated ones, which is annoying and must be fixed.

Basically, in 1.16, it is implemented in atom-languageclient, so no
need for a duplicated one.
The recent workaround for duplicated dollar signs need to be added
to the existing functionality, not replacing it. Fix this.
@machitgarha
Copy link
Collaborator Author

The regression is fixed. We should be ready, finally. :)

@Gert-dev
Copy link
Owner

LGTM, thanks!

@Gert-dev Gert-dev merged commit bf8b7eb into Gert-dev:master Jul 25, 2022
@Gert-dev
Copy link
Owner

Gert-dev commented Jul 25, 2022

@machitgarha I've also invited you as collaborator since I already accepted your request on GitLab. I'm still willing to review these changes and answer question as I'm doing now, but I haven't used Atom in a long time, so if you still do, you are probably in a better position to decide what works and what doesn't for Atom specifically 🙂 .

@machitgarha machitgarha deleted the fix-duplicating-autocompletion branch July 25, 2022 15:56
@machitgarha
Copy link
Collaborator Author

@Gert-dev, wow, thank you very much!

You mean, when I create PRs, I should ask you to review them before merging? Or you mean you continue to have a look on this project?

@Gert-dev
Copy link
Owner

Gert-dev commented Jul 26, 2022

@machitgarha I meant you don't (even) have to ask me for permission before merging, since I think you are in a better position to judge what works and what doesn't for Atom 🙂. However, if you are uncertain about something, or want to make an MR or get input regardless, I'll still happily do so 😄 .

@nelson6e65
Copy link

Thanks for this bugfix! 🥟

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.

Autocompletion for docblock tags does not replace @
3 participants