Browse Source

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.
Ihor Radchenko 3 years ago
parent
commit
312f39a05d
1 changed files with 7 additions and 4 deletions
  1. 7 4
      lisp/org-macs.el

+ 7 - 4
lisp/org-macs.el

@@ -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.
-    ;; 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)
+                            '(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 (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