branch: elpa/annotate commit 9ffdc1f76285445f2dfe1dfb594df49cbe290403 Author: Bastian Bechtold <bastian.becht...@jade-hs.de> Commit: Bastian Bechtold <bastian.becht...@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))))))