Skip to content

Commit

Permalink
consult--display-width: display takes precedence over invisible
Browse files Browse the repository at this point in the history
See #210. Thanks @oantolin.
  • Loading branch information
minad committed Feb 22, 2021
1 parent ed7ee1c commit 9370ca8
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions consult.el
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,16 @@ It does not correctly handle wide characters since `string-width' is not used. S
complicated `org-string-width' function, which handles more cases correctly."
(let ((pos 0) (width 0) (end (length string)))
(while (< pos end)
(let ((nexti (next-single-property-change pos 'invisible string end)))
(if (get-text-property pos 'invisible string)
(setq pos nexti)
(while (< pos nexti)
(let ((nextd (next-single-property-change pos 'display string nexti))
(display (get-text-property pos 'display string)))
(setq width (+ width (if (stringp display) (length display) (- nextd pos)))
pos nextd))))))
(let ((nextd (next-single-property-change pos 'display string end))
(display (get-text-property pos 'display string)))
(if (stringp display)
(setq width (+ width (length display))
pos nextd)
(while (< pos nextd)
(let ((nexti (next-single-property-change pos 'invisible string nextd)))
(unless (get-text-property pos 'invisible string)
(setq width (+ width ( - nexti pos))))
(setq pos nexti))))))
width))

(defun consult--string-hash (strings)
Expand Down

0 comments on commit 9370ca8

Please sign in to comment.