emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/diff-ansi 9992b0be2e: Fix an error with the timer attempti


From: ELPA Syncer
Subject: [nongnu] elpa/diff-ansi 9992b0be2e: Fix an error with the timer attempting to use a closed buffer
Date: Mon, 1 May 2023 19:11:47 -0400 (EDT)

branch: elpa/diff-ansi
commit 9992b0be2eac8c1bd8051f2ca8de4dc593dc6ff8
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>

    Fix an error with the timer attempting to use a closed buffer
---
 changelog.rst |  4 ++++
 diff-ansi.el  | 10 ++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/changelog.rst b/changelog.rst
index 886f6cbb18..a80bc89e0f 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -3,6 +3,10 @@
 Change Log
 ##########
 
+- Development (2023-05-02)
+
+  - Fix an error, attempting to use a closed buffer when ``diff-ansi-method`` 
is set to ``'progressive``.
+
 - Version 0.2 (2022-07-08)
 
   - Add ``diff-ansi-verbose-progress`` to support showing progress for 
progressive ansi conversion.
diff --git a/diff-ansi.el b/diff-ansi.el
index 47e1c5b7db..da38eeaeb8 100644
--- a/diff-ansi.el
+++ b/diff-ansi.el
@@ -643,7 +643,13 @@ Store the result in TARGET-BUF when non-nil."
 (defun diff-ansi-progressive-highlight-impl (buf beg range timer)
   "Callback to update colors for BUF in RANGE for TIMER.
 Argument BEG is only used to calculate the progress percentage."
-  (unless (input-pending-p)
+  (cond
+   ((not (buffer-live-p buf))
+    ;; The buffer was closed (most likely by the user) while the timer was 
running,  cancel it.
+    (cancel-timer timer))
+   ((input-pending-p)
+    nil)
+   (t
     (with-current-buffer buf
       (cond
        ((null diff-ansi--ansi-color-timer)
@@ -691,7 +697,7 @@ Argument BEG is only used to calculate the progress 
percentage."
 
           ;; Re-display outside the block that moves the cursor.
           (when do-redisplay
-            (redisplay))))))))
+            (redisplay)))))))))
 
 (defun diff-ansi--progressive-impl (beg end &optional target-buf)
   "Colorize the text between BEG and END using a timer.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]