From 88b8b9364331573646cfc5b481d47ecd3323f0d8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sat, 6 Mar 2021 21:15:33 +0000 Subject: [PATCH] Simplify eglot--apply-workspace-edit 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 | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 964658a8b23..f7632cb5996 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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." -- 2.39.2