]> git.eshelyaron.com Git - emacs.git/commitdiff
Apply text edits as a single undoable edit
authorJoão Távora <joaotavora@gmail.com>
Thu, 21 Jun 2018 16:48:10 +0000 (17:48 +0100)
committerJoão Távora <joaotavora@gmail.com>
Thu, 21 Jun 2018 17:21:30 +0000 (18:21 +0100)
As suggested by mkcms <k.michal@zoho.com>, but do it in
eglot--apply-text-edits, where it benefits all its users.

Also, just using undo-boundary is not enough, one needs
undo-amalgamate-change-group to mess with the boundaries already in
buffer-undo-list.

* eglot.el (eglot--apply-text-edits): Use
  undo-amalgamate-change-group.

GitHub-reference: close https://github.com/joaotavora/eglot/issues/22

lisp/progmodes/eglot.el

index 9e686eece63ce0c90172fbea9dafd6a5dcd9dbd7..2fdf433c55a7a9a52385c9fe767fe8006898acdc 100644 (file)
@@ -1584,7 +1584,8 @@ If SKIP-SIGNATURE, don't try to send textDocument/signatureHelp."
     (eglot--error "Edits on `%s' require version %d, you have %d"
                   (current-buffer) version eglot--versioned-identifier))
   (atomic-change-group
-    (let* ((howmany (length edits))
+    (let* ((change-group (prepare-change-group))
+           (howmany (length edits))
            (reporter (make-progress-reporter
                       (format "[eglot] applying %s edits to `%s'..."
                               howmany (current-buffer))
@@ -1604,6 +1605,7 @@ If SKIP-SIGNATURE, don't try to send textDocument/signatureHelp."
             (mapcar (eglot--lambda (&key range newText)
                       (cons newText (eglot--range-region range 'markers)))
                     edits))
+      (undo-amalgamate-change-group change-group)
       (progress-reporter-done reporter))))
 
 (defun eglot--apply-workspace-edit (wedit &optional confirm)