@@ -271,6 +271,31 @@ CONNECTION defaults to `cider-current-connection'."
271
271
(`" clj" " cljs" )
272
272
(_ " clj" )))))
273
273
274
+ (defvar cider--has-warned-about-bad-repl-type nil )
275
+
276
+ (defun cider--guess-cljs-connection ()
277
+ " Hacky way to find a ClojureScript REPL.
278
+ DO NOT USE THIS FUNCTION.
279
+ It was written only to be used in `cider-map-connections' , as a workaround
280
+ to a still-undetermined bug in the state-stracker backend."
281
+ (when-let ((project-connections (cider-find-connection-buffer-for-project-directory
282
+ nil :all-connections ))
283
+ (cljs-conn
284
+ ; ; So we have multiple connections. Look for the connection type we
285
+ ; ; want, prioritizing the current project.
286
+ (or (seq-find (lambda (c ) (string-match " \\ bCLJS\\ b" (buffer-name c)))
287
+ project-connections)
288
+ (seq-find (lambda (c ) (string-match " \\ bCLJS\\ b" (buffer-name c)))
289
+ (cider-connections)))))
290
+ (unless cider--has-warned-about-bad-repl-type
291
+ (setq cider--has-warned-about-bad-repl-type t )
292
+ (read-char
293
+ (concat " The ClojureScript REPL seems to be is misbehaving."
294
+ (substitute-command-keys
295
+ " \n We have applied a workaround, but please also file a bug report with `\\[cider-report-bug]' ." )
296
+ " \n Press any key to continue." )))
297
+ cljs-conn))
298
+
274
299
(defun cider-map-connections (function which &optional any-mode )
275
300
" Call FUNCTION once for each appropriate connection.
276
301
The function is called with one argument, the connection buffer.
@@ -303,6 +328,8 @@ connection but can be invoked from any buffer (like `cider-refresh')."
303
328
(pcase which
304
329
(`:any (let ((type (cider-connection-type-for-buffer)))
305
330
(or (cider-current-connection type)
331
+ (when (equal type " cljs" )
332
+ (cider--guess-cljs-connection))
306
333
(err (substitute-command-keys
307
334
(format " needs a Clojure%s REPL.\n If you don't know what that means, you probably need to jack-in (%s ). "
308
335
(if (equal type " cljs" ) " Script" " " )
0 commit comments