bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behavi


From: Eli Zaretskii
Subject: bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behaviour
Date: Wed, 08 Jul 2020 17:10:10 +0300

tags 42254 notabug
thanks

> From: Fernando Peña <ferpb1999@gmail.com>
> Date: Tue, 7 Jul 2020 23:55:12 +0200
> 
> I've noticed that when displaying line numbers with
> display-line-numbers-mode, the buffer shifts to the right to make space
> for one more digit before the line whose number has one more digit
> appears on the screen.
> 
> The line number where it shifts seems to depend on the width of the
> frame, but for example with 3 digits, the buffer shifts around line 90,
> before the 100th is on the screen. This happens even if the file has
> less than 100 lines, leaving and excessive space on the left side of the
> line numbers.
> 
> I'd expect that the buffer only shifted to the left when it was strictly
> necessary. In this case, when the number 100 was shown on screen.
> 
> I hope it can be solved. I find it really annoying, especially when the
> file doesn't have line numbers with that extra digit.

This is not a bug, but the intended behavior.  The design of the
line-numbers display is optimized for speed, so line numbers are
produced on the fly, without knowing exactly how many lines will fit
in the window (knowing the latter would need to produce all the lines
in a window on each redisplay, which is significantly slower).
Because the display engine doesn't know how many lines will fit, it
guesses based on the smallest font used by the frame, so it usually
overestimates, and switches to the wider field slightly before that is
actually needed.

I think it is a very small price to pay for a feature that imposes
almost no slowdown on the display operations.

If this side effect annoys you too much, I suggest to customize the
variable display-line-numbers-width-start to a non-nil value, then the
width of the line-number fields will always be exactly how much is
needed for the buffer.





reply via email to

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