emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/eglot2emacs d2e842bbf5 098/120: Prefer documentchanges to change


From: João Távora
Subject: feature/eglot2emacs d2e842bbf5 098/120: Prefer documentchanges to changes in server-initiated edits
Date: Thu, 20 Oct 2022 07:17:06 -0400 (EDT)

branch: feature/eglot2emacs
commit d2e842bbf51134bfd33943247faa88db99a36842
Author: Theodor Thornhill <theo@thornhill.no>
Commit: GitHub <noreply@github.com>

    Prefer documentchanges to changes in server-initiated edits
    
    Some servers return both.
    
    PR: https://github.com/joaotavora/eglot/issues/949
    
    * eglot.el (eglot--apply-workspace-edit): When both documentChanges
    and changes are present, prefer the documentChanges.  By doing that we
    ensure that we don't double edit, rendering the document in an
    unusable state.
    
    GitHub-reference: fix https://github.com/joaotavora/eglot/issues/704
---
 lisp/progmodes/eglot.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 80f0b65470..e399b29f09 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -3016,8 +3016,12 @@ Returns a list as described in docstring of 
`imenu--index-alist'."
                          textDocument
                        (list (eglot--uri-to-path uri) edits version)))
                    documentChanges)))
-      (cl-loop for (uri edits) on changes by #'cddr
-               do (push (list (eglot--uri-to-path uri) edits) prepared))
+      (unless (and changes documentChanges)
+        ;; We don't want double edits, and some servers send both
+        ;; changes and documentChanges.  This unless ensures that we
+        ;; prefer documentChanges over changes.
+        (cl-loop for (uri edits) on changes by #'cddr
+                 do (push (list (eglot--uri-to-path uri) edits) prepared)))
       (if (or confirm
               (cl-notevery #'find-buffer-visiting
                            (mapcar #'car prepared)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]