]> git.eshelyaron.com Git - emacs.git/commitdiff
Disable display-line-numbers-mode in string-pixel-width (bug#59311)
authorJuri Linkov <juri@linkov.net>
Sun, 20 Nov 2022 18:02:20 +0000 (20:02 +0200)
committerJuri Linkov <juri@linkov.net>
Sun, 20 Nov 2022 18:02:20 +0000 (20:02 +0200)
* lisp/emacs-lisp/subr-x.el (string-pixel-width):
Turn off display-line-numbers-mode when it's enabled.

lisp/emacs-lisp/subr-x.el

index 6e4d88b4df354d0c8d781c8e5042c9192963e902..18087bc937fa477370351e2ec31f9c023ff14393 100644 (file)
@@ -322,6 +322,10 @@ as the new values of the bound variables in the recursive invocation."
     ;; Keeping a work buffer around is more efficient than creating a
     ;; new temporary buffer.
     (with-current-buffer (get-buffer-create " *string-pixel-width*")
+      ;; `display-line-numbers-mode' is enabled in internal buffers
+      ;; that breaks width calculation, so need to disable (bug#59311)
+      (when (bound-and-true-p 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)))))