diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 9c9c3152472..9c76d4abdef 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -747,7 +747,8 @@ eglot-execute (((Command)) (eglot--request server :workspace/executeCommand action)) (((CodeAction) edit command) (when edit - (eglot--apply-workspace-edit edit (eq eglot-confirm-server-initiated-edits t))) + (let ((confirm (and (eq eglot-confirm-server-initiated-edits 'diff) 'diff))) + (eglot--apply-workspace-edit edit confirm))) (when command (eglot--request server :workspace/executeCommand command)))))) (cl-defgeneric eglot-initialization-options (server) @@ -3401,7 +3402,9 @@ eglot--apply-text-edits (progress-reporter-done reporter)))) (defun eglot--apply-workspace-edit (wedit &optional confirm) - "Apply the workspace edit WEDIT. If CONFIRM, ask user first." + "Apply the workspace edit WEDIT. +CONFIRM should have a value as specified in the user option +`eglot-confirm-server-initiated-edits'." (eglot--dbind ((WorkspaceEdit) changes documentChanges) wedit (let ((prepared (mapcar (eglot--lambda ((TextDocumentEdit) textDocument edits) @@ -3448,7 +3451,8 @@ eglot--apply-workspace-edit (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 (path edits version) in prepared + ((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!"))))))) @@ -3466,7 +3470,7 @@ eglot-rename (eglot--request (eglot--current-server-or-lose) :textDocument/rename `(,@(eglot--TextDocumentPositionParams) :newName ,newname)) - (and current-prefix-arg eglot-confirm-server-initiated-edits))) + (and current-prefix-arg (or eglot-confirm-server-initiated-edits 'confirm)))) (defun eglot--region-bounds () "Region bounds if active, else bounds of things at point."