emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/annotate 9ffdc1f762 060/372: fix for annotations with wide


From: ELPA Syncer
Subject: [nongnu] elpa/annotate 9ffdc1f762 060/372: fix for annotations with wide characters
Date: Fri, 4 Feb 2022 16:58:19 -0500 (EST)

branch: elpa/annotate
commit 9ffdc1f76285445f2dfe1dfb594df49cbe290403
Author: Bastian Bechtold <bastian.bechtold@jade-hs.de>
Commit: Bastian Bechtold <bastian.bechtold@jade-hs.de>

    fix for annotations with wide characters
---
 annotate.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/annotate.el b/annotate.el
index 6de7866df5..bce9b77981 100644
--- a/annotate.el
+++ b/annotate.el
@@ -416,14 +416,18 @@ annotation plus the newline."
              (substring text current-pos
                         (min (length text)
                              (+ current-pos available-width -1)))))
+        ;; discard characters until the string fits within the available width
+        ;; this can happen with unicode characters that are wider than one col
+        (while (> (string-width current-line) available-width)
+          (setq current-line (substring current-line 0 -1)))
         ;; strip partial last word if necessary, for word wrap:
         (when (and (string-match "[^ ]$" current-line)
                    (< (+ current-pos (length current-line)) (length text)))
           (string-match "[ ][^ ]+$" current-line)
           (setq current-line (replace-match " " nil nil current-line)))
         ;; append white space to the end of continued lines
-        (let ((postfix (if (< (+ current-pos (length current-line)) (length 
text))
-                           (make-string (- available-width (length 
current-line) 1) ? )
+        (let ((postfix (if (< (length current-line) (length text))
+                           (make-string (- available-width (string-width 
current-line) 1) ? )
                          "")))
           (setq lineated (concat lineated current-line postfix "\n")
                 current-pos (+ current-pos (length current-line))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]