branch: externals/eglot commit 0b9cffeda617679772f88f4c232f0b8704c1ae33 Author: João Távora <joaotav...@gmail.com> Commit: João Távora <joaotav...@gmail.com>
Per #22: Apply text edits atomically As suggested by mkcms <k.mic...@zoho.com>, but do it in eglot--apply-text-edits, where it benefits all its users. * eglot.el (eglot--apply-text-edits): Use atomic-change-group. --- eglot.el | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/eglot.el b/eglot.el index e96a3e6..489e365 100644 --- a/eglot.el +++ b/eglot.el @@ -1583,17 +1583,18 @@ If SKIP-SIGNATURE, don't try to send textDocument/signatureHelp." (unless (or (not version) (equal version eglot--versioned-identifier)) (eglot--error "Edits on `%s' require version %d, you have %d" (current-buffer) version eglot--versioned-identifier)) - (mapc (pcase-lambda (`(,newText ,beg . ,end)) - (save-restriction - (narrow-to-region beg end) - (let ((source (current-buffer))) - (with-temp-buffer - (insert newText) - (let ((temp (current-buffer))) - (with-current-buffer source (replace-buffer-contents temp))))))) - (mapcar (eglot--lambda (&key range newText) - (cons newText (eglot--range-region range 'markers))) - edits)) + (atomic-change-group + (mapc (pcase-lambda (`(,newText ,beg . ,end)) + (save-restriction + (narrow-to-region beg end) + (let ((source (current-buffer))) + (with-temp-buffer + (insert newText) + (let ((temp (current-buffer))) + (with-current-buffer source (replace-buffer-contents temp))))))) + (mapcar (eglot--lambda (&key range newText) + (cons newText (eglot--range-region range 'markers))) + edits))) (eglot--message "%s: Performed %s edits" (current-buffer) (length edits))) (defun eglot--apply-workspace-edit (wedit &optional confirm)