GNU bug report logs -
#42254
27.0.91; display-line-numbers-mode incoherent shifting behaviour
Previous Next
Reported by: Fernando Peña <ferpb1999 <at> gmail.com>
Date: Tue, 7 Jul 2020 23:12:02 UTC
Severity: normal
Tags: notabug
Found in version 27.0.91
Done: Stefan Kangas <stefan <at> marxist.se>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
tags 42254 notabug
thanks
> From: Fernando Peña <ferpb1999 <at> 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.
This bug report was last modified 4 years and 278 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.