Skip to content

Commit 46deb80

Browse files
committed
Default to sending :out and :err on the message's transport, not the transport that originated the session (fixes tpope/vim-foreplay#11)
1 parent 81580ae commit 46deb80

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/main/clojure/clojure/tools/nrepl/middleware/session.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
(.setLength buf 0)
4545
text))]
4646
(when (pos? (count text))
47-
(t/send transport
48-
(response-for *msg* :session session-id
49-
channel-type text))))))
47+
(t/send (or (:transport *msg*) transport)
48+
(response-for *msg* :session session-id
49+
channel-type text))))))
5050
true)))
5151

5252
(defn- session-in

src/test/clojure/clojure/tools/nrepl_test.clj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,27 @@
9090
combine-responses
9191
(select-keys [:value :out])))))
9292

93+
(def-repl-test sessionless-*out*
94+
(is (= "5\n:foo\n"
95+
(-> (repl-eval client "(println 5)(println :foo)")
96+
combine-responses
97+
:out))))
98+
99+
(def-repl-test session-*out*
100+
(is (= "5\n:foo\n"
101+
(-> (repl-eval session "(println 5)(println :foo)")
102+
combine-responses
103+
:out))))
104+
105+
(def-repl-test cross-transport-*out*
106+
(let [sid (-> session meta ::nrepl/taking-until :session)
107+
transport2 (nrepl/connect :port (:port *server*))]
108+
(transport/send transport2 {"op" "eval" "code" "(println :foo)"
109+
"session" sid})
110+
(is (->> (repeatedly #(transport/recv transport2 100))
111+
(take-while identity)
112+
(some #(= ":foo\n" (:out %)))))))
113+
93114
(def-repl-test streaming-out
94115
(is (= (for [x (range 10)]
95116
(str x \newline))

0 commit comments

Comments
 (0)