Skip to content

Commit ca27fcf

Browse files
committed
Improve evil-range
Account for beg > end case and case where beg or end are nil
1 parent 9de9a3c commit ca27fcf

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

evil-common.el

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2995,15 +2995,19 @@ type as per `evil-type-p', and PROPERTIES is a property list. If
29952995
beg or end are inside a sequence of composed characters, adjust
29962996
the positions to be outside of this sequence."
29972997
(let ((beg (evil-normalize-position beg))
2998-
(end (evil-normalize-position end)))
2999-
(let ((comp (find-composition beg)))
3000-
(when (and (listp comp) (nth 2 comp)) ; valid composition
3001-
(setq beg (nth 0 comp))))
3002-
(let ((comp (find-composition end)))
3003-
(when (and (listp comp) (nth 2 comp))
3004-
(setq end (nth 1 comp))))
2998+
(end (evil-normalize-position end))
2999+
beg-out end-out)
30053000
(when (and (numberp beg) (numberp end))
3006-
(append (list (min beg end) (max beg end))
3001+
(setq beg-out (min beg end))
3002+
(setq end-out (max beg end))
3003+
(let ((comp (find-composition beg-out)))
3004+
;; find-composition returns (FROM TO VALID-P)
3005+
(when (and (listp comp) (nth 2 comp))
3006+
(setq beg-out (nth 0 comp))))
3007+
(let ((comp (find-composition end-out)))
3008+
(when (and (listp comp) (nth 2 comp))
3009+
(setq end-out (nth 1 comp))))
3010+
(append (list beg-out end-out)
30073011
(when (evil-type-p type)
30083012
(list type))
30093013
properties))))

0 commit comments

Comments
 (0)