Skip to content

Commit f7781ca

Browse files
committed
Fixed preview logic.
1 parent 7c187ac commit f7781ca

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ivy-file-preview.el

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,12 @@
7777
(defun ivy-file-preview--open-file (fn pos)
7878
"Open the file path (FN).
7979
POS can either be an integer or cons cell represent line number and columns."
80-
(setq ivy-file-preview--selected-file fn)
8180
(if (file-exists-p fn) (find-file fn) (switch-to-buffer fn))
8281
(cond ((consp pos)
8382
(ivy-file-preview--goto-line (car pos))
8483
(move-to-column (cdr pos)))
8584
((integerp pos) (goto-char (1+ pos)))
86-
(t (error "Undefined pos details: %s" pos))))
85+
(t (error "Undefined position details: %s" pos))))
8786

8887
(defun ivy-file-preview--do-preview (project-dir fn pos)
8988
"Do file preview execution.
@@ -112,9 +111,10 @@ POS can either be an integer or cons cell represent line number and columns."
112111

113112
(defun ivy-file-preview--cancel-revert ()
114113
"Revert frame status if user cancel the commands."
115-
(unless ivy-exit
116-
(switch-to-buffer (pop ivy-file-preview--window-status))
117-
(set-window-point minibuffer-scroll-window (pop ivy-file-preview--window-status))))
114+
(if ivy-exit
115+
(setq ivy-file-preview--selected-file "")
116+
(switch-to-buffer (nth 0 ivy-file-preview--window-status))
117+
(set-window-point minibuffer-scroll-window (nth 1 ivy-file-preview--window-status))))
118118

119119
(defun ivy-file-preview--enter ()
120120
"Execution after minibuffer setup."
@@ -125,11 +125,11 @@ POS can either be an integer or cons cell represent line number and columns."
125125

126126
(defun ivy-file-preview--exit ()
127127
"Execution before minibuffer exits."
128+
(ivy-file-preview--cancel-revert) ; If already empty, revert it.
128129
(delete-dups ivy-file-preview--preview-files)
129130
(dolist (fn ivy-file-preview--preview-files)
130131
(unless (string= ivy-file-preview--selected-file fn)
131132
(kill-buffer (f-filename fn))))
132-
(ivy-file-preview--cancel-revert) ; If already empty, revert it.
133133
(setq ivy-file-preview--selected-file "")
134134
(setq ivy-file-preview--preview-files '()))
135135

0 commit comments

Comments
 (0)