Skip to content

Commit 6101815

Browse files
committed
fix js repl completion
1 parent 07aa3df commit 6101815

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/renderer/reepl/replumb.cljs

+8-6
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,10 @@ cljs.js/*load-fn*
237237
(js-attrs proto))))))
238238

239239
(defn js-completion
240-
[text]
240+
[mode text]
241241
(let [parts (vec (.split text "."))
242242
completing (or (last parts) "")
243-
prefix #(str "js/" (str/join "." (conj (vec (butlast parts)) %)))
243+
prefix #(str (when (= mode :cljs) "js/") (str/join "." (conj (vec (butlast parts)) %)))
244244
possibles (js-attrs (reduce aget js/window (butlast parts)))]
245245
(->> possibles
246246
(filter #(not= -1 (.indexOf % completing)))
@@ -289,10 +289,12 @@ cljs.js/*load-fn*
289289
(filter matches? names))))))
290290

291291
(defn process-apropos
292-
[text]
293-
(if (zero? (.indexOf text "js/"))
294-
(js-completion (.slice text 3))
295-
(cljs-completion text)))
292+
[mode text]
293+
(case mode
294+
:js (js-completion mode text)
295+
:cljs (if (zero? (.indexOf text "js/"))
296+
(js-completion mode (.slice text 3))
297+
(cljs-completion text))))
296298

297299
(defn get-forms
298300
[m]

src/renderer/reepl/views.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
[]
2323
[reepl/repl
2424
:execute #(replumb/run-repl (if (= @(rf/subscribe [:repl-mode]) :cljs) %1 (str "(js/eval \"" %1 "\")")) {:warning-as-error true} %2)
25-
:complete-word replumb/process-apropos
25+
:complete-word (fn [text] (replumb/process-apropos @(rf/subscribe [:repl-mode]) text))
2626
:get-docs replumb/process-doc
2727
:state repl-state
2828
:show-value-opts

0 commit comments

Comments
 (0)