Skip to content

Commit f249570

Browse files
committed
Fix printing to stdout inside a future
1 parent 38fdf8c commit f249570

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/leiningen/clojure_lsp/binary.clj

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,24 @@
7070
(io/file (global-cache-dir) "version.txt"))
7171

7272
(defn ^:private run-lsp! [^File path args]
73-
(let [p (process/process {:cmd (concat [(.getAbsolutePath path)] args)})]
74-
(future
75-
(with-open [out-rdr ^BufferedReader (io/reader (:out p))]
76-
(loop []
77-
(when-let [line (.readLine out-rdr)]
78-
(println line)
79-
(recur)))))
80-
(future
81-
(with-open [out-rdr ^BufferedReader (io/reader (:err p))]
82-
(binding [*out* *err*]
83-
(loop []
84-
(when-let [line (.readLine out-rdr)]
85-
(println line)
86-
(recur))))))
73+
(let [p (process/process {:cmd (concat [(.getAbsolutePath path)] args)})
74+
out-fut (future
75+
(with-open [out-rdr ^BufferedReader (io/reader (:out p))]
76+
(loop []
77+
(when-let [line (.readLine out-rdr)]
78+
(println line)
79+
(flush)
80+
(recur)))))
81+
err-fut (future
82+
(with-open [out-rdr ^BufferedReader (io/reader (:err p))]
83+
(binding [*out* *err*]
84+
(loop []
85+
(when-let [line (.readLine out-rdr)]
86+
(println line)
87+
(flush)
88+
(recur))))))]
89+
@out-fut
90+
@err-fut
8791
@p))
8892

8993
(defn ^:private download-server? [server-path server-version-path version]

0 commit comments

Comments
 (0)