]> git.eshelyaron.com Git - emacs.git/commitdiff
Simplify eglot--apply-workspace-edit
authorJoão Távora <joaotavora@gmail.com>
Sat, 6 Mar 2021 21:15:33 +0000 (21:15 +0000)
committerJoão Távora <joaotavora@gmail.com>
Sat, 6 Mar 2021 21:15:33 +0000 (21:15 +0000)
Suggested by Brian Leung.

* eglot.el (eglot--apply-workspace-edit): simplify

GitHub-reference: fix https://github.com/joaotavora/eglot/issues/620

lisp/progmodes/eglot.el

index 964658a8b233fdb8c2da81ad15cc1d2b3674ea0f..f7632cb59964b158f712e65dcf77b4ce4af2e565 100644 (file)
@@ -2530,8 +2530,7 @@ is not active."
                      (eglot--dbind ((VersionedTextDocumentIdentifier) uri version)
                          textDocument
                        (list (eglot--uri-to-path uri) edits version)))
-                   documentChanges))
-          edit)
+                   documentChanges)))
       (cl-loop for (uri edits) on changes by #'cddr
                do (push (list (eglot--uri-to-path uri) edits) prepared))
       (if (or confirm
@@ -2541,17 +2540,11 @@ is not active."
                    (format "[eglot] Server wants to edit:\n  %s\n Proceed? "
                            (mapconcat #'identity (mapcar #'car prepared) "\n  ")))
             (eglot--error "User cancelled server edit")))
-      (while (setq edit (car prepared))
-        (pcase-let ((`(,path ,edits ,version)  edit))
-          (with-current-buffer (find-file-noselect path)
-            (eglot--apply-text-edits edits version))
-          (pop prepared))
-        t)
-      (unwind-protect
-          (if prepared (eglot--warn "Caution: edits of files %s failed."
-                                    (mapcar #'car prepared))
-            (eldoc)
-            (eglot--message "Edit successful!"))))))
+      (cl-loop for edit in prepared
+               for (path edits version) = edit
+               do (with-current-buffer (find-file-noselect path)
+                    (eglot--apply-text-edits edits version))
+               finally (eldoc) (eglot--message "Edit successful!")))))
 
 (defun eglot-rename (newname)
   "Rename the current symbol to NEWNAME."