branch: master
commit 8d124c8903d1346899e29f5d929d1a05d0c5de50
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
ivy.el (ivy-completion-in-region): Fix length bug
Fixes #1251
---
ivy.el | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/ivy.el b/ivy.el
index 8279e09..44216e9 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2008,9 +2008,14 @@ See `completion-in-region' for further information."
(if (null comps)
(message "No matches")
(let* ((len (ivy-completion-common-length (car comps)))
- (initial (if (= len 0)
- ""
- (substring str (- len)))))
+ (str-len (length str))
+ (initial (cond ((= len 0)
+ "")
+ ((> len str-len)
+ (setq len str-len)
+ str)
+ (t
+ (substring str (- len))))))
(nconc comps nil)
(delete-region (- end len) end)
(setq ivy-completion-beg (- end len))