Fix string-pixel-width with global setting of display-line-numbers

* lisp/emacs-lisp/subr-x.el (string-pixel-width):
Instead of checking for display-line-numbers-mode, set the
display-line-numbers variable to nil (bug#67248).
This commit is contained in:
Dmitry Gutov 2023-11-18 18:35:18 +02:00
parent d9e43f2197
commit 0128495afd

View file

@ -322,10 +322,9 @@ as the new values of the bound variables in the recursive invocation."
;; Keeping a work buffer around is more efficient than creating a ;; Keeping a work buffer around is more efficient than creating a
;; new temporary buffer. ;; new temporary buffer.
(with-current-buffer (get-buffer-create " *string-pixel-width*") (with-current-buffer (get-buffer-create " *string-pixel-width*")
;; If `display-line-numbers-mode' is enabled in internal ;; If `display-line-numbers' is enabled in internal buffers
;; buffers, it breaks width calculation, so disable it (bug#59311) ;; (e.g. globally), it breaks width calculation (bug#59311)
(when (bound-and-true-p display-line-numbers-mode) (setq-local display-line-numbers nil)
(display-line-numbers-mode -1))
(delete-region (point-min) (point-max)) (delete-region (point-min) (point-max))
;; Disable line-prefix and wrap-prefix, for the same reason. ;; Disable line-prefix and wrap-prefix, for the same reason.
(setq line-prefix nil (setq line-prefix nil