Skip to content

Commit 523f740

Browse files
committed
Make evil-range aware of composed characters
A composed character is a way of visually replacing a string of characters with a single glyph. If beg in the call to evil-range lies in this hidden sequence, adjust the position to the beginning of the sequence. Similarly, make sure end comes at the end of any such hidden sequence. The purpose is to prevent evil from unintentionally modifying part of a hidden sequence of characters.
1 parent df84837 commit 523f740

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

evil-common.el

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2990,11 +2990,18 @@ If no description is available, return the empty string."
29902990

29912991
(defun evil-range (beg end &optional type &rest properties)
29922992
"Return a list (BEG END [TYPE] PROPERTIES...).
2993-
BEG and END are buffer positions (numbers or markers),
2994-
TYPE is a type as per `evil-type-p', and PROPERTIES is
2995-
a property list."
2993+
BEG and END are buffer positions (numbers or markers), TYPE is a
2994+
type as per `evil-type-p', and PROPERTIES is a property list. If
2995+
beg or end are inside a sequence of composed characters, adjust
2996+
the positions to be outside of this sequence."
29962997
(let ((beg (evil-normalize-position beg))
29972998
(end (evil-normalize-position end)))
2999+
(when-let* ((comp (find-composition beg))
3000+
(valid (nth 2 comp)))
3001+
(setq beg (nth 0 comp)))
3002+
(when-let* ((comp (find-composition end))
3003+
(valid (nth 2 comp)))
3004+
(setq end (nth 1 comp)))
29983005
(when (and (numberp beg) (numberp end))
29993006
(append (list (min beg end) (max beg end))
30003007
(when (evil-type-p type)

0 commit comments

Comments
 (0)