From: João Távora Date: Sun, 27 May 2018 13:17:36 +0000 (+0100) Subject: Correctly apply workspace edits in documentchanges form X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~531 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=882b571693992b5f2780e97070aa30265eab2a08;p=emacs.git Correctly apply workspace edits in documentchanges form This was breaking M-x eglot-rename for cquery * eglot.el (eglot--apply-workspace-edit): Fix and simplify. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index cd0ee654776..fa12577c694 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1491,39 +1491,30 @@ If SKIP-SIGNATURE, don't try to send textDocument/signatureHelp." (defun eglot--apply-workspace-edit (wedit &optional confirm) "Apply the workspace edit WEDIT. If CONFIRM, ask user first." - (let (prepared) - (cl-destructuring-bind (&key changes documentChanges) - wedit - (cl-loop - for change on documentChanges - do (push (cl-destructuring-bind (&key textDocument edits) change - (cl-destructuring-bind (&key uri version) textDocument - (list (eglot--uri-to-path uri) edits version))) - prepared)) + (cl-destructuring-bind (&key changes documentChanges) wedit + (let ((prepared + (mapcar (eglot--lambda (&key textDocument edits) + (cl-destructuring-bind (&key uri version) 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))) - (if (or confirm - (cl-notevery #'find-buffer-visiting - (mapcar #'car prepared))) - (unless (y-or-n-p - (format "[eglot] Server requests to edit %s files.\n %s\n\ -Proceed? " - (length prepared) - (mapconcat #'identity - (mapcar #'car prepared) - "\n "))) - (eglot--error "User cancelled server edit"))) - (unwind-protect - (let (edit) - (while (setq edit (car prepared)) - (cl-destructuring-bind (path edits &optional version) edit - (with-current-buffer (find-file-noselect path) - (eglot--apply-text-edits edits version)) - (pop prepared)))) - (if prepared - (eglot--warn "Caution: edits of files %s failed." - (mapcar #'car prepared)) - (eglot--message "Edit successful!"))))) + do (push (list (eglot--uri-to-path uri) edits) prepared)) + (if (or confirm + (cl-notevery #'find-buffer-visiting + (mapcar #'car prepared))) + (unless (y-or-n-p + (format "[eglot] Server wants to edit:\n %s\n Proceed? " + (mapconcat #'identity (mapcar #'car prepared) "\n "))) + (eglot--error "User cancelled server edit"))) + (unwind-protect + (let (edit) (while (setq edit (car prepared)) + (cl-destructuring-bind (path edits &optional version) edit + (with-current-buffer (find-file-noselect path) + (eglot--apply-text-edits edits version)) + (pop prepared)))) + (if prepared (eglot--warn "Caution: edits of files %s failed." + (mapcar #'car prepared)) + (eglot--message "Edit successful!")))))) (defun eglot-rename (newname) "Rename the current symbol to NEWNAME."