Subject: bug#59311: 29.0.50; tab-bar global-mode-string affected by global-display-line-numbers

From: Eli Zaretskii <[email-masked]>
Date: Sat, 19 Nov 2022 21:46:53 +0200

> From: Juri Linkov <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Sat, 19 Nov 2022 21:03:08 +0200
> 
> >> @@ -322,6 +322,8 @@ string-pixel-width
> >>      (with-current-buffer (get-buffer-create " *string-pixel-width*")
> >> +      (when display-line-numbers-mode
> >> +        (display-line-numbers-mode -1))
> >>        (delete-region (point-min) (point-max))
> >>        (insert string)
> >>        (car (buffer-text-pixel-size nil nil t)))))
> >
> > Yes.  Or subtract what (line-number-display-width t) returns (it will
> > return zero when line-numbers are turned OFF).
> 
> Shouldn't then buffer-text-pixel-size subtract line-number-display-width?
> Isn't this the responsibility of buffer-text-pixel-size,
> not responsibility of a caller like string-pixel-width?

No, because line-numbers take space, and some use cases of
buffer-text-pixel-size want to know that.  Only the caller knows whether the
line-numbers should or shouldn't be included.  The principle is that we
measure the space taken in the text-area, no matter how it is used.  (There
are other display features that affect the result, for example,
line-prefix.)