-
Notifications
You must be signed in to change notification settings - Fork 200
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
Snippet based completion inserts text twice #82
Comments
It's very odd that I can't reproduce this. Can you present a reproduction recipe from |
I'm running this in a stripped down version of emacs 26 config with only helm, company, yas, and eglot packages. I'm doing this with eglot master HEAD code with clangd language server in C++. |
Can you remove helm from the equation? |
Assuming you've got everything installed with package.el, you could start emacs with
|
Same issue with emacs -Q |
That's very odd. Also, normally when I request an Can you provide the actual line you used and the steps to start eglot? Alternatively, can you start with the steps that I give below, in the Eglot checkout directory and with Emacs 26.1?
The result, in a gif: By the way, clangd-6.0 doesn't provide any snippets for me, so I had to use cquery, as you see above. Which exact version of |
Figured out the issue. The solution I suggested should solve it. The command I'm running is
I also added some For instance, following is the relevant stuff in my completionItem.
So, eglot inserts the label and puts point at the end of "const" in the label it just inserted. Then, it takes bounds-of-thing-at-point, which returns the bounds of "const" and deletes the const instead of deleting the entire completion label that it just inserted. Then it inserts the snippet text. The combined result of which renders the effect of inserting the text twice. The solution I suggested doesn't make the assumption that the label will contain exactly one "thing". That's why it should work. |
Indeed. Company unexpectedly (and needlessly) calls this function more than once.
I never said it didn't. But I make it a point to understand a problem before I apply any solution. Should be fixed with a fix similar to yours. |
…ppet completions Suggested by Amol Mandhane. * eglot.el (eglot-completion-at-point): Use length of obj in :exit-function
…ppet completions Suggested by Amol Mandhane. * eglot.el (eglot-completion-at-point): Use length of obj in :exit-function
Suggested by Amol Mandhane. * eglot.el (eglot-completion-at-point): Use length of obj in :exit-function #82: joaotavora/eglot#82
Suggested by Amol Mandhane. * eglot.el (eglot-completion-at-point): Use length of obj in :exit-function GitHub-reference: close joaotavora/eglot#82
When snippet based completion is triggered, the completion text is inserted twice with snippets enabled on second text.
I think the part of
(delete-region (car bounds) (point))
in:exit-function
is the culprit. I locally replaced it with(delete-backward-char (length obj))
and it works fine.The text was updated successfully, but these errors were encountered: