]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/subr.el (activate-change-group): Fix bug#33341
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 27 Nov 2020 14:43:56 +0000 (09:43 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 27 Nov 2020 14:43:56 +0000 (09:43 -0500)
lisp/subr.el
test/lisp/subr-tests.el

index e009dcc2b9ad9ea4b4f32945762abdb5d97e3188..1cf3a49fe4fbf2b80888f84ce3dcfc7fbe0b0b15 100644 (file)
@@ -3036,7 +3036,10 @@ to `accept-change-group' or `cancel-change-group'."
   (dolist (elt handle)
     (with-current-buffer (car elt)
       (if (eq buffer-undo-list t)
-         (setq buffer-undo-list nil)))))
+         (setq buffer-undo-list nil)
+       ;; Add a boundary to make sure the upcoming changes won't be
+       ;; merged with any previous changes (bug#33341).
+       (undo-boundary)))))
 
 (defun accept-change-group (handle)
   "Finish a change group made with `prepare-change-group' (which see).
index 67f7fc97496155b516550e71f396d0de6185fd35..e3f798d11cf7ea83f78e4a9bb0de8fe394ee3f1f 100644 (file)
@@ -551,5 +551,17 @@ See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19350."
   (should (equal (replace-regexp-in-string "\\`\\|x" "z" "--xx--")
                  "z--zz--")))
 
+(ert-deftest subr-tests--change-group-33341 ()
+  (with-temp-buffer
+    (buffer-enable-undo)
+    (insert "0\n")
+    ;; (undo-boundary)
+    (let ((g (prepare-change-group)))
+      (activate-change-group g)
+      (insert "b\n")
+      (insert "c\n")
+      (cancel-change-group g))
+    (should (equal (buffer-string) "0\n"))))
+
 (provide 'subr-tests)
 ;;; subr-tests.el ends here