diff options
| author | Feng Shu <tumashu@163.com> | 2020-05-21 11:08:57 +0800 |
|---|---|---|
| committer | Feng Shu <tumashu@163.com> | 2020-05-21 11:19:18 +0800 |
| commit | 61cb32e0aa23e1a9451f1d76dc5d29d867830de5 (patch) | |
| tree | fa1c67c80694d0a9c576b0e316f0e348b77a66b7 | |
| parent | ae9bafe94fe6b77b6fe45766ae6172646f6a5d50 (diff) | |
Fix swiper-avy and ivy-posframe are having trouble #80
| -rw-r--r-- | ivy-posframe.el | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/ivy-posframe.el b/ivy-posframe.el index 49cfb09..5679222 100644 --- a/ivy-posframe.el +++ b/ivy-posframe.el @@ -453,21 +453,37 @@ selection, non-nil otherwise." (interactive) (unless (require 'avy nil 'noerror) (error "Package avy isn't installed")) + (unless (require 'avy nil 'noerror) + (error "Package avy isn't installed")) + (cl-case (length ivy-text) + (0 + (user-error "Need at least one char of input")) + (1 + (let ((swiper-min-highlight 1)) + (swiper--update-input-ivy)))) (unless (string= ivy-text "") (let ((candidate (ivy-posframe--swiper-avy-candidate))) - (if (eq (cdr candidate) (ivy-posframe--window)) - (let ((cand-text (with-current-buffer ivy-posframe-buffer - (save-excursion - (goto-char (car candidate)) - (buffer-substring-no-properties - (line-beginning-position) - (line-end-position)))))) - (ivy-set-index (cl-position cand-text ivy--old-cands :test #'string=)) - (ivy--exhibit) - (ivy-done) - (ivy-call)) - (ivy-quit-and-run - (avy-action-goto (avy-candidate-beg candidate))))))) + (cond ((eq (cdr candidate) (ivy-posframe--window)) + (let ((cand-text (with-current-buffer ivy-posframe-buffer + (save-excursion + (goto-char (car candidate)) + (buffer-substring + (line-beginning-position) + (line-end-position)))))) + (ivy-set-index + ;; cand-text may include "> ", using a hack way + ;; to deal with it. + (or (cl-some (lambda (n) + (cl-position (substring cand-text n) ivy--old-cands :test #'string=)) + '(0 1 2 3 4)) + 0)) + (ivy--exhibit) + (ivy-done) + (ivy-call))) + ((or (consp candidate) + (number-or-marker-p candidate)) + (ivy-quit-and-run + (avy-action-goto (avy-candidate-beg candidate)))))))) ;;; Variables |
