Function: eglot--apply-workspace-edit
eglot--apply-workspace-edit is a byte-compiled function defined in
eglot.el.gz.
Signature
(eglot--apply-workspace-edit WEDIT &optional CONFIRM)
Documentation
Apply the workspace edit WEDIT. If CONFIRM, ask user first.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/eglot.el.gz
(defun eglot--apply-workspace-edit (wedit &optional confirm)
"Apply the workspace edit WEDIT. If CONFIRM, ask user first."
(eglot--dbind ((WorkspaceEdit) changes documentChanges) wedit
(let ((prepared
(mapcar (eglot--lambda ((TextDocumentEdit) textDocument edits)
(eglot--dbind ((VersionedTextDocumentIdentifier) uri version)
textDocument
(list (eglot--uri-to-path uri) edits version)))
documentChanges)))
(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)))
(unless (y-or-n-p
(format "[eglot] Server wants to edit:\n %s\n Proceed? "
(mapconcat #'identity (mapcar #'car prepared) "\n ")))
(jsonrpc-error "User canceled server edit")))
(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!")))))