@@ -288,27 +288,28 @@ If CURRENT-OV is non-nil it create overlay that are currently selected."
288288(defun ivy-file-preview--open-file (fn pos )
289289 " Open the file path (FN) and move to POS.
290290If POS is nil then it won't moves."
291- (let ((is-fild -p t ) (just-fn (f-filename fn)))
291+ (let ((is-file -p t ) (just-fn (f-filename fn)))
292292 (cond ((file-exists-p fn)
293293 (setq ivy-file-preview--selected-file fn)
294294 (find-file fn))
295- ((not ivy-file-preview-details) (setq is-fild -p nil ))
295+ ((not ivy-file-preview-details) (setq is-file -p nil ))
296296 ((or (find-buffer-visiting fn) (get-buffer just-fn))
297297 (setq ivy-file-preview--selected-file just-fn)
298298 (switch-to-buffer just-fn))
299299 (t
300300 (setq ivy-file-preview--selected-file " "
301- is-fild-p nil )))
302- (cond ((consp pos)
303- (ivy-file-preview--goto-line (car pos))
304- (move-to-column (cdr pos))
305- (recenter ))
306- ((integerp pos)
307- (goto-char (1+ pos))
308- (recenter ))
309- ((not pos) (goto-char (point-min )))
310- (t (error " Invalid position details: %s " pos)))
311- is-fild-p))
301+ is-file-p nil )))
302+ (when is-file-p
303+ (cond ((consp pos)
304+ (ivy-file-preview--goto-line (car pos))
305+ (move-to-column (cdr pos))
306+ (recenter ))
307+ ((integerp pos)
308+ (goto-char (1+ pos))
309+ (recenter ))
310+ ((not pos) (goto-char (point-min )))
311+ (t (error " Invalid position details: %s " pos))))
312+ is-file-p))
312313
313314(defun ivy-file-preview--do-preview (fn pos )
314315 " Do file preview execution.
@@ -338,14 +339,15 @@ FN is the file path. POS can either be one of the following type:
338339(defun ivy-file-preview--read-selection (selection )
339340 " Read SELECTION and return list of data (file, line, column)."
340341 (let ((buf-lst (buffer-list )) buf-name buf-regex sel-lst)
341- (cl-some (lambda (buf )
342- (setq buf-name (buffer-name buf)
343- buf-regex (format " ^%s " (regexp-quote buf-name)))
344- (string-match-p buf-regex selection))
345- buf-lst)
342+ (setq found
343+ (cl-some (lambda (buf )
344+ (setq buf-name (buffer-name buf)
345+ buf-regex (format " ^%s " (regexp-quote buf-name)))
346+ (string-match-p buf-regex selection))
347+ buf-lst))
346348 (setq selection (s-replace-regexp buf-regex " " selection)
347349 sel-lst (split-string selection " :" ))
348- (list buf-name (nth 1 sel-lst) (nth 2 sel-lst))))
350+ (list ( if found buf-name ( nth 0 sel-lst)) (nth 1 sel-lst) (nth 2 sel-lst))))
349351
350352(defun ivy-file-preview--after-select (&rest _ )
351353 " Execution after selection."
0 commit comments