From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#42254: 27.0.91; display-line-numbers-mode incoherent shifting behaviour Date: Wed, 08 Jul 2020 17:10:10 +0300 Message-ID: <83pn96qerh.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3963"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 42254@debbugs.gnu.org To: Fernando =?UTF-8?Q?Pe=C3=B1a?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 08 16:11:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jtAn0-0000wF-MC for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Jul 2020 16:11:10 +0200 Original-Received: from localhost ([::1]:47550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jtAmz-00062w-AK for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Jul 2020 10:11:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jtAms-00061z-8v for bug-gnu-emacs@gnu.org; Wed, 08 Jul 2020 10:11:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55512) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jtAmr-0008Qq-Vu for bug-gnu-emacs@gnu.org; Wed, 08 Jul 2020 10:11:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jtAmr-0002ov-RF for bug-gnu-emacs@gnu.org; Wed, 08 Jul 2020 10:11:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Jul 2020 14:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42254 X-GNU-PR-Package: emacs Original-Received: via spool by 42254-submit@debbugs.gnu.org id=B42254.159421740810768 (code B ref 42254); Wed, 08 Jul 2020 14:11:01 +0000 Original-Received: (at 42254) by debbugs.gnu.org; 8 Jul 2020 14:10:08 +0000 Original-Received: from localhost ([127.0.0.1]:38825 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jtAlz-0002nX-1r for submit@debbugs.gnu.org; Wed, 08 Jul 2020 10:10:07 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jtAlx-0002mn-EM; Wed, 08 Jul 2020 10:10:05 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:36887) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jtAls-0008Bj-80; Wed, 08 Jul 2020 10:10:00 -0400 Original-Received: from [176.228.60.248] (port=3995 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jtAlr-0005EB-Ok; Wed, 08 Jul 2020 10:10:00 -0400 In-Reply-To: (message from Fernando =?UTF-8?Q?Pe=C3=B1a?= on Tue, 7 Jul 2020 23:55:12 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:182836 Archived-At: tags 42254 notabug thanks > From: Fernando Peña > 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.