track-changes.el: Add a workaround for bug#70541

* lisp/emacs-lisp/track-changes.el (track-changes-inconsistent-state-p):
 New function.
* lisp/progmodes/eglot.el (eglot--track-changes-signal): Use it.
This commit is contained in:
Stefan Monnier 2024-05-03 13:23:00 -04:00
parent 15c77f2fce
commit b6d4e81a48
2 changed files with 31 additions and 8 deletions

View file

@ -367,6 +367,17 @@ and re-enable the TRACKER corresponding to ID."
;; as to avoid nested invocations.
(cl-pushnew id track-changes--clean-trackers))))
(defun track-changes-inconsistent-state-p ()
"Return whether the current buffer is in an inconsistent state.
Ideally `before/after-change-functions' should be called for each and every
buffer change, but some packages make transient changes without
running those hooks.
This function tries to detect those situations so clients can decide
to postpone their work to a later time when the buffer is hopefully
returned to a consistent state."
(or (equal track-changes--buffer-size (buffer-size))
inhibit-modification-hooks))
;;;; Auxiliary functions.
(defun track-changes--clean-state ()