[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 190f472227 1/2: org-string-width: Round fractional
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 190f472227 1/2: org-string-width: Round fractional widths |
Date: |
Mon, 22 Jul 2024 15:58:46 -0400 (EDT) |
branch: externals/org
commit 190f4722279dcaa7a14efb3ee974a9d6a39fdfa3
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
org-string-width: Round fractional widths
* lisp/org-macs.el (org-string-width): Fix zero-width
spaces (displayed as 1 pixel) being treated and full-width characters.
* testing/lisp/test-org-macs.el (test-org/string-width): Add new test.
Reported-by: Daniel <daniel@algebra20.de>
Link: https://orgmode.org/list/877cddbfkb.fsf@algebra20.de
---
lisp/org-macs.el | 2 +-
testing/lisp/test-org-macs.el | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index a6ff0e5451..b15fdbebdc 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -1218,7 +1218,7 @@ STRING width. When REFERENCE-FACE is nil, `default' face
is used."
(setq symbol-width (org-buffer-text-pixel-width))))
(if pixels
pixel-width
- (ceiling pixel-width symbol-width)))))))
+ (round pixel-width symbol-width)))))))
(defmacro org-current-text-column ()
"Like `current-column' but ignore display properties.
diff --git a/testing/lisp/test-org-macs.el b/testing/lisp/test-org-macs.el
index 93f00a4c51..5287a7aa5e 100644
--- a/testing/lisp/test-org-macs.el
+++ b/testing/lisp/test-org-macs.el
@@ -43,6 +43,8 @@
"Test `org-string-width' specifications."
(should (= 1 (org-string-width "a")))
(should (= 0 (org-string-width "")))
+ ;; Zero-width space
+ (should (= 0 (org-string-width "")))
;; Ignore invisible characters.
(should (= 0 (org-string-width #("a" 0 1 (invisible t)))))
(should (= 1 (org-string-width #("ab" 0 1 (invisible t)))))