-
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
Completing deletes too much text (with snippets or TextEdits) #160
Comments
Can we try just |
Hmm, I tried it a bit and with emacs -Q I get
in new buffers. When undo-list is not empty, it doesn't appear to work reliably either. I also tried using change groups which I cancel in However I got the best results with just using the bounds which we already calculate from diff --git a/eglot.el b/eglot.el
index d9c1c3a..fe68f87 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1610,7 +1610,9 @@ is not active."
(eglot--snippet-expansion-fn))))
(when (or fn textEdit)
;; Undo the completion
- (delete-region (- (point) (length comp)) (point)))
+ (delete-region (+ (- (point) (length comp))
+ (if bounds (- (cdr bounds) (car bounds)) 0))
+ (point)))
(cond (textEdit
(cl-destructuring-bind (&key range newText) textEdit
(pcase-let ((`(,beg . ,end) (eglot--range-region range))) |
Good. Let's go with this then. Just add another line of comment or so after "Undo the completion" sumarrily explaining the problem and the strategy. And if possible add a test for one of these newer servers. Thanks! |
Alright, I will also add a general test for TextEdits in completion. This will require downloading or building a server which supports them on travis though. Although maybe one of the servers we use already supports them, I will check. |
Fixes a slight regression from #160. * eglot.el (eglot-completion-at-point): When there is plain `insertText' snippet, delete the full completion text.
* eglot.el (eglot-completion-at-point): In :exit-function, delete only the region of buffer that was inserted by completion.
Fixes a slight regression from joaotavora/eglot#160. * eglot.el (eglot-completion-at-point): When there is plain `insertText' snippet, delete the full completion text.
* eglot.el (eglot-completion-at-point): In :exit-function, delete only the region of buffer that was inserted by completion.
Fixes a slight regression from joaotavora/eglot#160. * eglot.el (eglot-completion-at-point): When there is plain `insertText' snippet, delete the full completion text.
* eglot.el (eglot-completion-at-point): In :exit-function, delete only the region of buffer that was inserted by completion. #160: joaotavora/eglot#160
Fixes a slight regression from #160. * eglot.el (eglot-completion-at-point): When there is plain `insertText' snippet, delete the full completion text. #167: joaotavora/eglot#167 #160: joaotavora/eglot#160
* eglot.el (eglot-completion-at-point): In :exit-function, delete only the region of buffer that was inserted by completion. GitHub-reference: fix joaotavora/eglot#160
Fixes a slight regression from joaotavora/eglot#160. * eglot.el (eglot-completion-at-point): When there is plain `insertText' snippet, delete the full completion text. GitHub-reference: fix joaotavora/eglot#167
Given this file
When I set point to 71 and complete to 'baz', I end up with
(notice that Emacs deleted one parenthesis at the end of completed line)
This happens if either TextEdits or snippets are present in the completion.
The reason is that the completion provided to
:exit-function
is not the inserted text, but the whole completed symbol, fromcar
of completion bounds to point.In this case Emacs deletes one to many character because the completed symbol is
b
. If the completed symbol isba
, Emacs will delete 2 characters, etc.Events:
The text was updated successfully, but these errors were encountered: