GNU bug report logs - #42653
28.0.50; scroll-margin is sometimes ignored with hl-line/display-line-numbers-mode

Previous Next

Package: emacs;

Reported by: Kevin Liu <kevin <at> nivekuil.com>

Date: Sat, 1 Aug 2020 16:27:02 UTC

Severity: normal

Found in version 28.0.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

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 42653 in the body.
You can then email your comments to 42653 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#42653; Package emacs. (Sat, 01 Aug 2020 16:27:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kevin Liu <kevin <at> nivekuil.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 01 Aug 2020 16:27:02 GMT) Full text and rfc822 format available.

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

From: Kevin Liu <kevin <at> nivekuil.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; scroll-margin is sometimes ignored with
 hl-line/display-line-numbers-mode
Date: Sat, 01 Aug 2020 03:39:57 -0700
This has been a bug since at least 24.x, and I think Eli even fixed
something like it once before:
https://lists.gnu.org/archive/html/bug-gnu-emacs/2012-11/msg00838.html

This problem is a little different because it involves scroll-margin.
When scrolling up, the cursor will seem to ignore it until it hits the
top, and then jumps back down to the margin.

To quickly reproduce this, run emacs -Q and then eval

(progn
 (global-hl-line-mode)
 (setq scroll-margin 5)
 (setq scroll-conservatively 101)
 (view-hello-file)
 (end-of-buffer))

Then (previous-line) until you see the problem.

Further reference:
- https://emacs.stackexchange.com/questions/48340/line-numbers-break-scroll-margin
- https://github.com/syl20bnr/spacemacs/issues/8224




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42653; Package emacs. (Sat, 01 Aug 2020 16:45:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Kevin Liu <kevin <at> nivekuil.com>
Cc: 42653 <at> debbugs.gnu.org
Subject: Re: bug#42653: 28.0.50; scroll-margin is sometimes ignored with
 hl-line/display-line-numbers-mode
Date: Sat, 01 Aug 2020 19:44:24 +0300
> From: Kevin Liu <kevin <at> nivekuil.com>
> Date: Sat, 01 Aug 2020 03:39:57 -0700
> 
> (progn
>  (global-hl-line-mode)
>  (setq scroll-margin 5)
>  (setq scroll-conservatively 101)
>  (view-hello-file)
>  (end-of-buffer))
> 
> Then (previous-line) until you see the problem.

I only see this when EOB is before end of the window, which I don't
think is a bug.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42653; Package emacs. (Sat, 01 Aug 2020 18:26:02 GMT) Full text and rfc822 format available.

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

From: Kevin Liu <kevin <at> nivekuil.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 42653 <at> debbugs.gnu.org
Subject: Re: bug#42653: 28.0.50; scroll-margin is sometimes ignored with
 hl-line/display-line-numbers-mode
Date: Sat, 01 Aug 2020 10:32:13 -0700
On  1 August 2020 09:44, Eli Zaretskii <eliz <at> gnu.org> wrote:

> I only see this when EOB is before end of the window, which I don't
> think is a bug.

Could you elaborate on this?  I don't understand why it's proper for
hl-line-mode and display-line-numbers-mode to affect scrolling behavior
in any scenario, much less this one.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42653; Package emacs. (Sun, 02 Aug 2020 15:34:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Kevin Liu <kevin <at> nivekuil.com>
Cc: 42653 <at> debbugs.gnu.org
Subject: Re: bug#42653: 28.0.50; scroll-margin is sometimes ignored with
 hl-line/display-line-numbers-mode
Date: Sun, 02 Aug 2020 18:33:35 +0300
> From: Kevin Liu <kevin <at> nivekuil.com>
> Cc: 42653 <at> debbugs.gnu.org
> Date: Sat, 01 Aug 2020 10:32:13 -0700
> 
> On  1 August 2020 09:44, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
> > I only see this when EOB is before end of the window, which I don't
> > think is a bug.
> 
> Could you elaborate on this?  I don't understand why it's proper for
> hl-line-mode and display-line-numbers-mode to affect scrolling behavior
> in any scenario, much less this one.

Indeed, they shouldn't.  I've misinterpreted the test case, sorry.

There was a 15-year old code that handled the logic of scroll-margin
when EOB is visible, and it had a bug.  This should now be fixed on
the master branch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42653; Package emacs. (Sun, 02 Aug 2020 20:55:03 GMT) Full text and rfc822 format available.

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

From: Kevin Liu <kevin <at> nivekuil.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 42653 <at> debbugs.gnu.org
Subject: Re: bug#42653: 28.0.50; scroll-margin is sometimes ignored with
 hl-line/display-line-numbers-mode
Date: Sun, 02 Aug 2020 13:24:34 -0700
Thanks!  This has honestly bugged me forever and will improve my Emacs
experience immeasurably.

> /* if EOB is visible, disable bottom margin */

This is a very interesting change that I didn't know I wanted, and I
really like it.  I see two issues right now:

1. If (hl-line-mode 1), then scrolling down as you reach EOB will
continue "collapsing" the margin, moving the cursor but not scrolling
beyond EOB, until it hits the actual EOB line.  At that point,
scroll-margin will again take effect and the screen will suddenly scroll
down by scroll-margin lines (7 in my case).  This seems like a bug,
off-by-one maybe?

2. The intended behavior of disabling the bottom margin as EOB
approaches seems to only apply when (hl-line-mode 1) or
(display-line-numbers-mode 1).  This means that enabling these modes
still affects scrolling behavior, which I think is fundamentally
unexpected.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42653; Package emacs. (Mon, 03 Aug 2020 02:29:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Kevin Liu <kevin <at> nivekuil.com>
Cc: 42653 <at> debbugs.gnu.org
Subject: Re: bug#42653: 28.0.50; scroll-margin is sometimes ignored with
 hl-line/display-line-numbers-mode
Date: Mon, 03 Aug 2020 05:28:19 +0300
> From: Kevin Liu <kevin <at> nivekuil.com>
> Cc: 42653 <at> debbugs.gnu.org
> Date: Sun, 02 Aug 2020 13:24:34 -0700
> 
> 1. If (hl-line-mode 1), then scrolling down as you reach EOB will
> continue "collapsing" the margin, moving the cursor but not scrolling
> beyond EOB, until it hits the actual EOB line.  At that point,
> scroll-margin will again take effect and the screen will suddenly scroll
> down by scroll-margin lines (7 in my case).  This seems like a bug,
> off-by-one maybe?
> 
> 2. The intended behavior of disabling the bottom margin as EOB
> approaches seems to only apply when (hl-line-mode 1) or
> (display-line-numbers-mode 1).  This means that enabling these modes
> still affects scrolling behavior, which I think is fundamentally
> unexpected.

Please show a test case for each of these two, as I don't think I've
seen them in my testing.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42653; Package emacs. (Mon, 03 Aug 2020 03:19:01 GMT) Full text and rfc822 format available.

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

From: Kevin Liu <kevin <at> nivekuil.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 42653 <at> debbugs.gnu.org
Subject: Re: bug#42653: 28.0.50; scroll-margin is sometimes ignored with
 hl-line/display-line-numbers-mode
Date: Sun, 02 Aug 2020 20:18:20 -0700
On  2 August 2020 19:28, Eli Zaretskii <eliz <at> gnu.org> wrote:

> Please show a test case for each of these two, as I don't think I've
> seen them in my testing.

My original test case should demonstrate this as well, as the buffer
should be scrolled beyond EOB.  Then (previous-line) up until EOB is
back out of view, then scroll back down and the problem should be
visible.  I also recorded a video for illustration in case this is one
of those only-on-my-machine cases (which it might be, as I built off a
merged native-comp branch): https://www.youtube.com/watch?v=EKrbrVGbEZw

(progn
  (global-hl-line-mode)
  (setq scroll-margin 5)
  (setq scroll-conservatively 101)
  (view-hello-file)
  (end-of-buffer))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42653; Package emacs. (Mon, 03 Aug 2020 14:59:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Kevin Liu <kevin <at> nivekuil.com>
Cc: 42653 <at> debbugs.gnu.org
Subject: Re: bug#42653: 28.0.50; scroll-margin is sometimes ignored with
 hl-line/display-line-numbers-mode
Date: Mon, 03 Aug 2020 17:57:41 +0300
> From: Kevin Liu <kevin <at> nivekuil.com>
> Cc: 42653 <at> debbugs.gnu.org
> Date: Sun, 02 Aug 2020 20:18:20 -0700
> 
> On  2 August 2020 19:28, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
> > Please show a test case for each of these two, as I don't think I've
> > seen them in my testing.
> 
> My original test case should demonstrate this as well, as the buffer
> should be scrolled beyond EOB.  Then (previous-line) up until EOB is
> back out of view, then scroll back down and the problem should be
> visible.  I also recorded a video for illustration in case this is one
> of those only-on-my-machine cases (which it might be, as I built off a
> merged native-comp branch): https://www.youtube.com/watch?v=EKrbrVGbEZw
> 
> (progn
>   (global-hl-line-mode)
>   (setq scroll-margin 5)
>   (setq scroll-conservatively 101)
>   (view-hello-file)
>   (end-of-buffer))

Very well, I've now removed the EOB test.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42653; Package emacs. (Thu, 10 Sep 2020 21:20:03 GMT) Full text and rfc822 format available.

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

From: Dale Sedivec <dale <at> codefu.org>
To: 42653 <at> debbugs.gnu.org
Subject: Emacs now recentering very aggressively
Date: Thu, 10 Sep 2020 16:18:55 -0500
Hi, as of commit a07ec21bf24b, which is said to address bug #42653, Emacs started recentering as I scroll up.  Here's a minimal reproduction case:

1. emacs -Q

2. Display anything in the header line: (setq-default header-line-format "foo")

3. Open any file longer than a few screenfuls: M-x find-library RET subr RET

4. Enable which-function-mode: M-x which-function-mode RET

(display-line-numbers-mode also triggers this problem, but I find which-function-mode more interesting since it doesn't change the display of the buffer at all, only the mode line.)

5. M-> (end-of-buffer)

6. Page up a few times with M-v (scroll-down-command)

Expected behavior: Point is sitting at the bottom line of the window no matter how many times you page up

Observed behavior: The window is recentered, usually after ever page up, with a slight delay

Here's a video of this behavior, in case it helps: https://www.dropbox.com/s/i7m2h9ltwrpxxy3/emacs_scrolling.mp4?dl=0

emacs-version: GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G6020)) of 2020-09-10

I built this today from master, 70a8d06fe1.

I can stop this from happening with (setq scroll-conservatively 101), so perhaps the behavior is intentional?  However, the fact that point stays at the bottom of the window for a brief instant, and then only recenters when (I am **guessing**) which-func-update runs leads me to believe this is unintentional behavior.

Please let me know if you need any more information.

Regards,
Dale



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42653; Package emacs. (Fri, 11 Sep 2020 10:30:03 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Dale Sedivec <dale <at> codefu.org>
Cc: 42653 <at> debbugs.gnu.org
Subject: Re: bug#42653: Emacs now recentering very aggressively
Date: Fri, 11 Sep 2020 12:29:04 +0200
Dale Sedivec <dale <at> codefu.org> writes:

> 2. Display anything in the header line: (setq-default header-line-format "foo"
[...]

> Expected behavior: Point is sitting at the bottom line of the window
> no matter how many times you page up
>
> Observed behavior: The window is recentered, usually after ever page
> up, with a slight delay

Ah!  So that's what this is.  I spent some time the other day tracking
down why this was happening in erc buffers, so I was looking at recent
erc changes.  But erc is one of the few modes I have with a header line
that I sometimes scroll back in, so that explains it.

> I can stop this from happening with (setq scroll-conservatively 101),
> so perhaps the behavior is intentional?  However, the fact that point
> stays at the bottom of the window for a brief instant, and then only
> recenters when (I am **guessing**) which-func-update runs leads me to
> believe this is unintentional behavior.

Yes, it's definitely unintentional.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42653; Package emacs. (Sat, 12 Sep 2020 08:09:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dale Sedivec <dale <at> codefu.org>
Cc: 42653 <at> debbugs.gnu.org
Subject: Re: bug#42653: Emacs now recentering very aggressively
Date: Sat, 12 Sep 2020 11:08:35 +0300
> From: Dale Sedivec <dale <at> codefu.org>
> Date: Thu, 10 Sep 2020 16:18:55 -0500
> 
> 1. emacs -Q
> 
> 2. Display anything in the header line: (setq-default header-line-format "foo")
> 
> 3. Open any file longer than a few screenfuls: M-x find-library RET subr RET
> 
> 4. Enable which-function-mode: M-x which-function-mode RET
> 
> (display-line-numbers-mode also triggers this problem, but I find which-function-mode more interesting since it doesn't change the display of the buffer at all, only the mode line.)
> 
> 5. M-> (end-of-buffer)
> 
> 6. Page up a few times with M-v (scroll-down-command)
> 
> Expected behavior: Point is sitting at the bottom line of the window no matter how many times you page up
> 
> Observed behavior: The window is recentered, usually after ever page up, with a slight delay

Thanks, there was a subtle thinko in commit a07ec21bf24b, should be
fixed now.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42653; Package emacs. (Wed, 09 Feb 2022 09:51:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 42653 <at> debbugs.gnu.org, Dale Sedivec <dale <at> codefu.org>
Subject: Re: bug#42653: 28.0.50; scroll-margin is sometimes ignored with
 hl-line/display-line-numbers-mode
Date: Wed, 09 Feb 2022 10:49:53 +0100
Eli Zaretskii <eliz <at> gnu.org> writes:

> Thanks, there was a subtle thinko in commit a07ec21bf24b, should be
> fixed now.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I'm therefore closing this bug report.  If there's still a bug here,
please respond to the debbugs address and we'll reopen.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 42653 <at> debbugs.gnu.org and Kevin Liu <kevin <at> nivekuil.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 09 Feb 2022 09:51:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 09 Mar 2022 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 41 days ago.

Previous Next


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