Skip to content

Commit

Permalink
Improve evil-range
Browse files Browse the repository at this point in the history
Account for beg > end case and case where beg or end are nil
  • Loading branch information
justbur committed Aug 22, 2022
1 parent 9de9a3c commit ca27fcf
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions evil-common.el
Original file line number Diff line number Diff line change
Expand Up @@ -2995,15 +2995,19 @@ type as per `evil-type-p', and PROPERTIES is a property list. If
beg or end are inside a sequence of composed characters, adjust
the positions to be outside of this sequence."
(let ((beg (evil-normalize-position beg))
(end (evil-normalize-position end)))
(let ((comp (find-composition beg)))
(when (and (listp comp) (nth 2 comp)) ; valid composition
(setq beg (nth 0 comp))))
(let ((comp (find-composition end)))
(when (and (listp comp) (nth 2 comp))
(setq end (nth 1 comp))))
(end (evil-normalize-position end))
beg-out end-out)
(when (and (numberp beg) (numberp end))
(append (list (min beg end) (max beg end))
(setq beg-out (min beg end))
(setq end-out (max beg end))
(let ((comp (find-composition beg-out)))
;; find-composition returns (FROM TO VALID-P)
(when (and (listp comp) (nth 2 comp))
(setq beg-out (nth 0 comp))))
(let ((comp (find-composition end-out)))
(when (and (listp comp) (nth 2 comp))
(setq end-out (nth 1 comp))))
(append (list beg-out end-out)
(when (evil-type-p type)
(list type))
properties))))
Expand Down

0 comments on commit ca27fcf

Please sign in to comment.