Skip to content

Commit

Permalink
nrepl: don't allow (dirac! :join) from within dirac nrepl session
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin committed Sep 25, 2016
1 parent cea87f0 commit a037828
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/nrepl/dirac/nrepl/controls.clj
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
(defn ^:dynamic session-disjoined-msg []
(str "Your session was disjoined from Dirac. Now you are back in normal Clojure session."))

(defn ^:dynamic cannot-match-dirac-session-msg []
(defn ^:dynamic cannot-join-dirac-session-msg []
(str "Your session is a Dirac session. This type of session cannot join any other session."))

(defn ^:dynamic cannot-match-clojure-session-msg []
Expand Down Expand Up @@ -222,6 +222,7 @@
(defmethod dirac! :join [_ & [matcher]]
(let [session (sessions/get-current-session)]
(cond
(sessions/dirac-session? session) (error-println (cannot-join-dirac-session-msg))
(nil? matcher) (announce-join! (sessions/join-session-with-most-recent-matcher! session))
(number? matcher) (announce-join! (sessions/join-session-with-number-matcher! session matcher))
(string? matcher) (announce-join! (sessions/join-session-with-substr-matcher! session matcher))
Expand All @@ -246,7 +247,7 @@
(defmethod dirac! :match [_ & _]
(let [session (sessions/get-current-session)]
(cond
(sessions/dirac-session? session) (error-println (cannot-match-dirac-session-msg))
(sessions/dirac-session? session) (error-println (cannot-join-dirac-session-msg))
(not (sessions/joined-session? session)) (error-println (cannot-match-clojure-session-msg))
:else (let [description (sessions/get-target-session-info session)
tags (sessions/list-matching-sessions-tags session)]
Expand Down

0 comments on commit a037828

Please sign in to comment.