]> git.eshelyaron.com Git - emacs.git/commitdiff
(track-changes--after): Fix problem found in bug#73041
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 17 Oct 2024 15:39:19 +0000 (11:39 -0400)
committerEshel Yaron <me@eshelyaron.com>
Tue, 22 Oct 2024 18:50:54 +0000 (20:50 +0200)
When calling `track-changes--before` (e.g. because of a missing
b-f-c or for some other reason), it sets `track-changes--before-end`
to the right value so we shouldn't increment it right after.
Also, we should update `track-changes--buffer-size` before
calling `track-changes--before` so it doesn't risk signaling
a spurious inconsistency.

* lisp/emacs-lisp/track-changes.el (track-changes--after):
Update `track-changes--buffer-size` earlier, and don't increment
`track-changes--before-end` when we call `track-changes--before`.

(cherry picked from commit 90c6880a922029ba6e57adb2afe00a6fa57ef7fe)

lisp/emacs-lisp/track-changes.el

index 7d1c928c92a67f03b06742ad63c44272ae26a556..2d45f41ae9405241920bca5ef51e1c77a7b760ff 100644 (file)
@@ -591,16 +591,16 @@ Details logged to `track-changes--error-log'")
 (defun track-changes--after (beg end len)
   (track-changes--trace)
   (cl-assert track-changes--state)
-  (and (eq track-changes--before-clean 'unset)
-       (not track-changes--before-no)
-       ;; This can be a sign that a `before-change-functions' went missing,
-       ;; or that we called `track-changes--clean-state' between
-       ;; a `before-change-functions' and `after-change-functions'.
-       (track-changes--before beg end))
-  (setq track-changes--before-clean nil)
   (let ((offset (- (- end beg) len)))
-    (cl-incf track-changes--before-end offset)
     (cl-incf track-changes--buffer-size offset)
+    (if (and (eq track-changes--before-clean 'unset)
+             (not track-changes--before-no))
+         ;; This can be a sign that a `before-change-functions' went missing,
+         ;; or that we called `track-changes--clean-state' between
+         ;; a `before-change-functions' and `after-change-functions'.
+         (track-changes--before beg end)
+      (cl-incf track-changes--before-end offset))
+    (setq track-changes--before-clean nil)
     (if (not (or track-changes--before-no
                  (save-restriction
                    (widen)