GNU bug report logs -
#32460
27.0.50; diff-mode sometimes doesn't refine hunks
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Thu, 16 Aug 2018 21:42:02 UTC
Severity: minor
Tags: fixed
Found in version 27.0.50
Fixed in version 27.1
Done: charles <at> aurox.ch
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
It's difficult to debug a sporadic problem when automatic diff
refinement doesn't display refined overlays on some diff hunks
occasionally. Looking at the code, it seems there is a possible
race condition when diff--font-lock-refined calls diff-hunk-next
that sets a timer that later might remove and try to re-add again
overlays already added by the direct call of diff--refine-hunk
from diff--font-lock-refined. Also diff-hunk-next prevents
multiple consequent calls from refining a set of hunks
by checking diff--auto-refine-data.
To avoid such double refinement, this patch let-binds
diff-auto-refine-mode to nil before calling diff-hunk-next
for non-interactive navigation (it calls diff--refine-hunk
explicitly below):
[diff-refine.1.patch (text/x-diff, inline)]
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index b91a2ba45a..175687f184 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -2077,7 +2088,9 @@ diff--font-lock-refined
(point) 'diff--font-lock-refined nil max)))
(let* ((min (point))
(beg (or (ignore-errors (diff-beginning-of-hunk))
- (ignore-errors (diff-hunk-next) (point))
+ (ignore-errors (let ((diff-auto-refine-mode nil))
+ (diff-hunk-next))
+ (point))
max)))
(while (< beg max)
(let ((end
@@ -2092,7 +2105,10 @@ diff--font-lock-refined
(overlay-put ol 'modification-hooks
'(diff--font-lock-refine--refresh))))
(goto-char (max beg end))
- (setq beg (or (ignore-errors (diff-hunk-next) (point)) max)))))))
+ (setq beg (or (ignore-errors (let ((diff-auto-refine-mode nil))
+ (diff-hunk-next))
+ (point))
+ max)))))))
(defun diff--font-lock-refine--refresh (ol _after _beg _end &optional _len)
(delete-overlay ol))
This bug report was last modified 6 years and 119 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.