Skip to content

Commit

Permalink
fix: Ensure no properties when calc string len
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Feb 28, 2024
1 parent 3bd6315 commit 090f7d8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sideline.el
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,16 @@
(require 'shr)
(shr-string-pixel-width str)))

(defun sideline--str-no-props (str)
"Remove STR's text properties."
(with-temp-buffer
(insert str)
(buffer-substring-no-properties (point-min) (point-max))))

(defun sideline--str-len (str)
"Calculate STR in pixel width."
(let ((width (frame-char-width))
(str (sideline--str-no-props str))
(len (sideline--string-pixel-width str)))
(+ (/ len width)
(if (zerop (% len width)) 0 1)))) ; add one if exceeed
Expand Down

0 comments on commit 090f7d8

Please sign in to comment.