- (let* ((re (ivy--regex ivy-text))
- (str ivy--current)
- (num (if (string-match "^[0-9]+" str)
- (string-to-number (match-string 0 str))
- 0)))
- (goto-char (point-min))
- (when (cl-plusp num)
- (goto-char (point-min))
- (forward-line (1- num))
- (if (and (equal ivy-text "")
- (>= swiper--opoint (line-beginning-position))
- (<= swiper--opoint (line-end-position)))
- (goto-char swiper--opoint)
- (re-search-forward re (line-end-position) t))
- (isearch-range-invisible (line-beginning-position)
- (line-end-position))
- (unless (and (>= (point) (window-start))
- (<= (point) (window-end (ivy-state-window ivy-last) t)))
- (recenter)))
- (swiper--add-overlays re))))
-
-(defun swiper--add-overlays (re &optional beg end)
+ (when (> (length ivy--current) 0)
+ (let* ((re (replace-regexp-in-string
+ " " "\t"
+ (funcall ivy--regex-function ivy-text)))
+ (re (if (stringp re) re (caar re)))
+ (str (get-text-property 0 'display ivy--current))
+ (num (if (string-match "^[0-9]+" str)
+ (string-to-number (match-string 0 str))
+ 0)))
+ (unless (eq this-command 'ivy-yank-word)
+ (when (cl-plusp num)
+ (unless (if swiper--current-line
+ (eq swiper--current-line num)
+ (eq (line-number-at-pos) num))
+ (goto-char (point-min))
+ (if swiper-use-visual-line
+ (line-move (1- num))
+ (forward-line (1- num))))
+ (if (and (equal ivy-text "")
+ (>= swiper--opoint (line-beginning-position))
+ (<= swiper--opoint (line-end-position)))
+ (goto-char swiper--opoint)
+ (if (eq swiper--current-line num)
+ (when swiper--current-match-start
+ (goto-char swiper--current-match-start))
+ (setq swiper--current-line num))
+ (when (re-search-forward re (line-end-position) t)
+ (setq swiper--current-match-start (match-beginning 0))))
+ (isearch-range-invisible (line-beginning-position)
+ (line-end-position))
+ (unless (and (>= (point) (window-start))
+ (<= (point) (window-end (ivy-state-window ivy-last) t)))
+ (recenter))))
+ (swiper--add-overlays re)))))
+
+(defun swiper--add-overlays (re &optional beg end wnd)