Skip to content

Commit 7869bb0

Browse files
committed
Keep cursor in original window after eval
1 parent ed2c58d commit 7869bb0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/socket_repl/socket_repl_plugin.clj

+8-8
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,14 @@
110110
[f]
111111
(warn-if-disconnect* current-connection f))
112112

113-
(defn get-rlog-buffer-async
113+
(defn get-rlog-buffer
114114
"Returns a channel which contains the name of the buffer w/ b:rlog set, if
115115
one exists."
116116
[]
117117
(->> (nvim/vim-get-buffers)
118118
(filter #(nvim/buffer-get-var % "rlog"))
119119
(map nvim/buffer-get-name)
120-
first
121-
go))
120+
first))
122121

123122
(defn connect!
124123
"Connect to a socket repl. Adds the connection to the `current-connection`
@@ -223,16 +222,17 @@
223222
(update-last!)
224223
(let [file (-> @current-connection :file .getAbsolutePath)]
225224
(go
226-
(let [buffer-cmd (first (message/params msg))
227-
rlog-buffer (<! (get-rlog-buffer-async))
225+
(let [original-window (nvim/vim-get-current-window)
226+
buffer-cmd (first (message/params msg))
227+
rlog-buffer (get-rlog-buffer)
228228
rlog-buffer-visible? (when rlog-buffer
229229
(<! (nvim/buffer-visible?-async
230230
rlog-buffer)))]
231231
(when-not rlog-buffer-visible?
232-
(nvim/vim-command-async
232+
(nvim/vim-command
233233
(format "%s | nnoremap <buffer> q :q<cr> | :let b:rlog=1 | :call termopen('tail -f %s')"
234-
buffer-cmd file)
235-
(fn [_])))))
234+
buffer-cmd file))
235+
(nvim/vim-set-current-window original-window))))
236236
;; Don't return a core.async channel, else msgpack will fail to
237237
;; serialize it.
238238
"success"))))

0 commit comments

Comments
 (0)