Subject: Re: bug#76734: 31.0.50; The line numbers take more space than they need
From: Stefan Kangas <[email-masked]>
To: the_wurfkreuz <[email-masked]>, Eli Zaretskii <[email-masked]>
Cc: [email-masked]
Date: Tue, 4 Mar 2025 21:36:21 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

the_wurfkreuz via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <[email-masked]> writes:

> Sent with Proton Mail secure email.
>
> On Tuesday, March 4th, 2025 at 2:55 PM, Eli Zaretskii <[email-masked]> wrote:
>
>> tags 76734 notabug
>> thanks
>>
>> > Date: Tue, 04 Mar 2025 06:31:00 +0000
>> > From: the_wurfkreuz via "Bug reports for GNU Emacs,
>> > the Swiss army knife of text editors" [email-masked]
>> >
>> > When using the line-numbers mode, the line numbers start to take an
>> > additional space from a buffer way before the line count reaches 3
>> > digit numbers.
>> >
>> > Steps to reproduce:
>> >
>> > 1. Evaluate:
>> >
>> > (global-display-line-numbers-mode 1)
>> > (setq display-line-numbers 'visual
>> > display-line-numbers-type 'relative)
>> >
>> > (fringe-mode '(1 . 1))
>> >
>> > 2. Then create new lines in the same buffer using the newline
>> > command. In my case i get an additional space on a 38th line already.
>>
>>
>> This is by design. Emacs cannot know how many lines will actually be
>> shown in the window before it actually shows them all. By contrast,
>> it needs to decide how many columns to allocate for line numbers
>> before it displays even a single line, to avoid the annoying
>> horizontal movement of text as much as possible. So it sometimes errs
>> on the safe side (recall that some lines could be smaller than others
>> due to different fonts), to avoid the need to display the window
>> twice, which would significantly punish performance in this mode.
>>
>> Why is that a problem?
>
> If it's done so intentionally, then there is no inherent problem.

Yes, I think it's intentional here, sorry.  Thanks for the bug report,
nevertheless.

I guess the only thing left to do here is to close the bug; I'm doing
that with this message.