GNU bug report logs - #32460
27.0.50; diff-mode sometimes doesn't refine hunks

Previous Next

Package: emacs;

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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 32460 in the body.
You can then email your comments to 32460 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#32460; Package emacs. (Thu, 16 Aug 2018 21:42:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 16 Aug 2018 21:42:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.50; diff-mode sometimes doesn't refine hunks
Date: Thu, 16 Aug 2018 23:48:05 +0300
[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))

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32460; Package emacs. (Thu, 07 Mar 2019 19:14:02 GMT) Full text and rfc822 format available.

Message #8 received at 32460 <at> debbugs.gnu.org (full text, mbox):

From: charles <at> aurox.ch (Charles A. Roelli)
To: Juri Linkov <juri <at> linkov.net>
Cc: 32460 <at> debbugs.gnu.org
Subject: Re: bug#32460: 27.0.50; diff-mode sometimes doesn't refine hunks
Date: Thu, 07 Mar 2019 20:26:11 +0100
tags 32460 fixed
close 32460 27.1
quit

As Juri suggested, the fix for Bug#32991 probably fixed this bug.




Added tag(s) fixed. Request was from charles <at> aurox.ch (Charles A. Roelli) to control <at> debbugs.gnu.org. (Thu, 07 Mar 2019 19:14:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 32460 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net> Request was from charles <at> aurox.ch (Charles A. Roelli) to control <at> debbugs.gnu.org. (Thu, 07 Mar 2019 19:14:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32460; Package emacs. (Fri, 08 Mar 2019 03:08:02 GMT) Full text and rfc822 format available.

Message #15 received at 32460 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: charles <at> aurox.ch (Charles A. Roelli)
Cc: 32460 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#32460: 27.0.50; diff-mode sometimes doesn't refine hunks
Date: Thu, 07 Mar 2019 22:07:30 -0500
> 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




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 05 Apr 2019 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 359 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.