From: João Távora Date: Thu, 21 Jun 2018 13:53:50 +0000 (+0100) Subject: Apply text edits atomically X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~494 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=31b21e371da5676fbdac4a3f352eceb657a62180;p=emacs.git Apply text edits atomically As suggested by mkcms , but do it in eglot--apply-text-edits, where it benefits all its users. * eglot.el (eglot--apply-text-edits): Use atomic-change-group. GitHub-reference: per https://github.com/joaotavora/eglot/issues/22 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index e96a3e68e23..489e3658b11 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/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)