Skip to content

Commit

Permalink
Fix #234 with ctx-store
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Jul 14, 2022
1 parent b884333 commit 7c10146
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
applied-science/js-interop {:mvn/version "0.3.1"}
cljs-bean/cljs-bean {:mvn/version "1.8.0"}
org.babashka/sci
{:local/root "../babashka/sci"}
#_{:local/root "../babashka/sci"}
#_{:mvn/version "0.3.5"}
#_{:git/url "https://github.com/babashka/sci"
:git/sha "3f97ecb5bad66ab8cee5acb57f41b98ba5e1f87f"}
{:git/url "https://github.com/babashka/sci"
:git/sha "3611d7c72257cd9120c8554ef1a53f2eabf87f70"}
org.babashka/sci.configs
{:local/root "/Users/borkdude/dev/sci.configs"}
#_{:git/url "https://github.com/babashka/sci.configs"
:git/sha "3eed9938d0f3b76326ed81005c5ac9e5d6aeca3a"}
#_{:local/root "/Users/borkdude/dev/sci.configs"}
{:git/url "https://github.com/babashka/sci.configs"
:git/sha "f51eb77af54f34ade0e37695a52285808bfb5d55"}
org.clojure/tools.cli {:mvn/version "1.0.206"}
com.cognitect/transit-cljs {:mvn/version "0.8.269"}
#_#_prismatic/schema {:mvn/version "1.3.0"}
Expand Down
2 changes: 1 addition & 1 deletion src/nbb/impl/main.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Tooling:
repl?
(-> (esm/dynamic-import "./nbb_repl.js")
(.then (fn [_mod]
((-> (store/get-ctx) deref :env deref
((-> (store/get-ctx) :env deref
:namespaces (get 'nbb.repl) (get 'repl)))))))
(.then (fn [val]
(when (and expr (some? val))
Expand Down
12 changes: 6 additions & 6 deletions src/nbb/impl/repl_utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
(:require
[clojure.string :as str]
[goog.object :as gobject]
[sci.core :as sci]))
[sci.core :as sci]
[sci.ctx-store :as store]))

(defn the-sci-ns [ctx ns-sym]
(sci/find-ns ctx ns-sym))
Expand All @@ -28,8 +29,8 @@
(when (re-find pat (str sym-ns "/" sym-name))
[sym-ns (str sym-ns "/" sym-name)]))))))

(defn ns-imports->completions [sci-ctx-atom query-ns query]
(let [ctx @sci-ctx-atom
(defn ns-imports->completions [query-ns query]
(let [ctx (store/get-ctx)
[_ns-part name-part] (str/split query #"/")
resolved (sci/eval-string* ctx
(pr-str `(let [resolved# (resolve '~query-ns)]
Expand Down Expand Up @@ -59,10 +60,9 @@
completions)))))

(defn handle-complete* [{ns-str :ns
:keys [sci-ctx-atom]
:as request}]
(try
(let [ctx @sci-ctx-atom
(let [ctx (store/get-ctx)
sci-ns (when ns-str
(the-sci-ns ctx (symbol ns-str)))]
(sci/binding [sci/ns (or sci-ns @sci/ns)]
Expand All @@ -88,7 +88,7 @@
all-namespaces (->> (sci/eval-string* ctx "(all-ns)")
(map (fn [ns]
[(str ns) nil :qualified])))
from-imports (when has-namespace? (ns-imports->completions sci-ctx-atom query-ns query))
from-imports (when has-namespace? (ns-imports->completions query-ns query))
fully-qualified-names (when-not from-imports
(when has-namespace?
(let [ns (get alias->ns query-ns query-ns)
Expand Down

0 comments on commit 7c10146

Please sign in to comment.