org-string-width: Do not remove face info when PIXELS is non-nil

* lisp/org-macs.el (org-string-width): Do not remove the STRING faces
unless character width is requested.  Faces might alter pixel width of
the string and removing them would yield incorrect results.
This commit is contained in:
Ihor Radchenko 2022-04-24 13:51:13 +08:00
parent 9bc6c363da
commit 312f39a05d
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 7 additions and 4 deletions

View File

@ -968,12 +968,15 @@ Return width in pixels when PIXELS is non-nil."
(org--string-width-1 string)
;; Wrap/line prefix will make `window-text-pizel-size' return too
;; large value including the prefix.
(remove-text-properties 0 (length string)
'(wrap-prefix t line-prefix t)
string)
;; Face should be removed to make sure that all the string symbols
;; are using default face with constant width. Constant char width
;; is critical to get right string width from pixel width.
(remove-text-properties 0 (length string)
'(wrap-prefix t line-prefix t face t)
string)
;; is critical to get right string width from pixel width (not needed
;; when PIXELS are requested though).
(unless pixels
(remove-text-properties 0 (length string) '(face t) string))
(let (;; We need to remove the folds to make sure that folded table
;; alignment is not messed up.
(current-invisibility-spec