-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
x/tools/gopls: add insert-replace support (insertReplaceEdit) #40871
Comments
I'm not familiar with this codebase, but it appears that there might already be a commit relevant to a fix for this issue at https://go-review.googlesource.com/c/tools/+/196119/. There's also a related issue report that was frozen due to age at #34011. |
Also relevant to this behavior is the LSP client's |
This issue regressed since it was fixed in https://go-review.googlesource.com/c/tools/+/196119/ .
Interesting. Adding support for that could be the best way forward since preferences differ. |
Selfishly, I still prefer the behavior I advocated for in #34011, so any way that preserves the behavior will make me happy. 🙂 |
Sorry, I failed to read the second part of your comment 😊 |
Is anyone following up |
I don't have time at the moment to implement the I'll try to revisit at some point and implement the capability. |
still has this problem today |
still has this problem and this is annoying |
I can tackle this |
It has been tackled! See: Not yet merged though. But I can confirm that building gopls on this branch fixes the issue. |
Ah cool. Thanks for the heads up. |
Change https://go.dev/cl/587135 mentions this issue: |
InsertReplaceEdit is used instead of TextEdit in CompletionItem in editors that support it. These two types are alike in appearance but can be differentiated by the presence or absence of certain properties. UnmarshalJSON of the sum type tries to unmarshal as TextEdit only if unmarshal as InsertReplaceEdit fails. Due to this similarity, unmarshal with the different type never fails. Add a custom JSON unmarshaller for InsertReplaceEdit, so it fails when the required fields are missing. That makes Or_CompletionItem_textEdit decode TextEdit type correctly. For golang/go#40871 For golang/go#61215 Change-Id: I62471fa973fa376cad5eb3934522ff21c14e3647 Reviewed-on: https://go-review.googlesource.com/c/tools/+/587135 Reviewed-by: Peter Weinberger <pjw@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Looks like it has been merged 🥳 |
Currently gopls is overwriting the surrounding suffix (in addition to prefix) when inserting candidates:
I think it's from https://go-review.googlesource.com/c/tools/+/208501 changing the surrounding's range from
[ident.Pos(), c.pos]
to[ident.Pos(), ident.End()]
./cc @heschik
The text was updated successfully, but these errors were encountered: