@@ -288,27 +288,28 @@ If CURRENT-OV is non-nil it create overlay that are currently selected."
288
288
(defun ivy-file-preview--open-file (fn pos )
289
289
" Open the file path (FN) and move to POS.
290
290
If 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)))
292
292
(cond ((file-exists-p fn)
293
293
(setq ivy-file-preview--selected-file fn)
294
294
(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 ))
296
296
((or (find-buffer-visiting fn) (get-buffer just-fn))
297
297
(setq ivy-file-preview--selected-file just-fn)
298
298
(switch-to-buffer just-fn))
299
299
(t
300
300
(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))
312
313
313
314
(defun ivy-file-preview--do-preview (fn pos )
314
315
" Do file preview execution.
@@ -338,14 +339,15 @@ FN is the file path. POS can either be one of the following type:
338
339
(defun ivy-file-preview--read-selection (selection )
339
340
" Read SELECTION and return list of data (file, line, column)."
340
341
(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))
346
348
(setq selection (s-replace-regexp buf-regex " " selection)
347
349
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))))
349
351
350
352
(defun ivy-file-preview--after-select (&rest _ )
351
353
" Execution after selection."
0 commit comments