unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Fernando Peña" <ferpb1999@gmail.com>
Cc: 42254@debbugs.gnu.org
Subject: bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behaviour
Date: Wed, 08 Jul 2020 17:10:10 +0300	[thread overview]
Message-ID: <83pn96qerh.fsf@gnu.org> (raw)
In-Reply-To: <CAAnJb_H=cTi46SSts2auwj9sRzZ4YApRJOBtjTvUHxmH8_13Cg@mail.gmail.com> (message from Fernando Peña on Tue, 7 Jul 2020 23:55:12 +0200)

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	other threads:[~2020-07-08 14:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 21:55 bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behaviour Fernando Peña
2020-07-08 14:10 ` Eli Zaretskii [this message]
     [not found]   ` <CAAnJb_HZAVd2GOD7kScP_BkSRvZjkJosA2VjWz4J8jpnMdwjiQ@mail.gmail.com>
2020-07-08 14:50     ` Eli Zaretskii
2020-07-08 15:02       ` Fernando Peña
2020-07-08 15:09         ` Fernando Peña
2020-07-08 16:21         ` Eli Zaretskii
2020-07-08 17:02           ` Fernando Peña
2020-08-13  0:29           ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83pn96qerh.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=42254@debbugs.gnu.org \
    --cc=ferpb1999@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).