* bug#32460: 27.0.50; diff-mode sometimes doesn't refine hunks
@ 2018-08-16 20:48 Juri Linkov
2019-03-07 19:26 ` Charles A. Roelli
0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2018-08-16 20:48 UTC (permalink / raw)
To: 32460
[-- Attachment #1: Type: text/plain, Size: 729 bytes --]
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):
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: diff-refine.1.patch --]
[-- Type: text/x-diff, Size: 1253 bytes --]
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))
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#32460: 27.0.50; diff-mode sometimes doesn't refine hunks
2018-08-16 20:48 bug#32460: 27.0.50; diff-mode sometimes doesn't refine hunks Juri Linkov
@ 2019-03-07 19:26 ` Charles A. Roelli
2019-03-08 3:07 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Charles A. Roelli @ 2019-03-07 19:26 UTC (permalink / raw)
To: Juri Linkov; +Cc: 32460
tags 32460 fixed
close 32460 27.1
quit
As Juri suggested, the fix for Bug#32991 probably fixed this bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#32460: 27.0.50; diff-mode sometimes doesn't refine hunks
2019-03-07 19:26 ` Charles A. Roelli
@ 2019-03-08 3:07 ` Stefan Monnier
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2019-03-08 3:07 UTC (permalink / raw)
To: Charles A. Roelli; +Cc: 32460, Juri Linkov
> As Juri suggested, the fix for Bug#32991 probably fixed this bug.
As part of the fix for Bug#32991, I rewrote the code that visits "all"
hunks in a region, because that code had a bug which basically made it
skip every other hunk: in practice with jit-lock (where the granularity
is small enough that the region considered rarely contains more than one
hunk), it tended to "arbitrarily" miss some hunks every once in a while
(regardless of diff-hunk-next).
Not sure if this error was the cause of bug#32460 since you mention
interaction with diff-hunk-next, but I think it's indeed better to close
the bug for now and reopen it (or a new one) if it re-appears.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-08 3:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-16 20:48 bug#32460: 27.0.50; diff-mode sometimes doesn't refine hunks Juri Linkov
2019-03-07 19:26 ` Charles A. Roelli
2019-03-08 3:07 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.