Skip to content

Commit

Permalink
Fix slurp string
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Jun 17, 2024
1 parent 71553ee commit b4105f4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@lezer/highlight": "^1.0.0",
"@lezer/lr": "^1.0.0",
"@nextjournal/lezer-clojure": "1.0.0",
"squint-cljs": "0.7.105",
"squint-cljs": "0.7.111",
"w3c-keyname": "^2.2.4"
},
"comments": {
Expand Down
20 changes: 9 additions & 11 deletions src-shared/nextjournal/clojure_mode/commands.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@
(defn nav [dir]
(fn [state]
(u/update-ranges state
(j/fn [^:js {:as range :keys [from to empty]}]
(j/fn [^:js {:keys [from to empty]}]
(if empty
{:cursor (nav-position state from dir)}
{:cursor (j/get (u/from-to from to) (case dir -1 :from 1 :to))})))))

(defn nav-select [dir]
(fn [^js state]
(u/update-ranges state
(j/fn [^:js {:as range :keys [from to empty]}]
(j/fn [^:js {:keys [from to empty]}]
(if empty
{:range (n/balanced-range state from (nav-position state from dir))}
{:range (j/let [^:js {:keys [from to]} (u/from-to from to)]
Expand Down Expand Up @@ -158,22 +158,20 @@
:changes (case direction
1
(let [edge (n/down-last parent)]
[{:from (-> target n/end)
:insert (n/name edge)}
#js [#js {:from (-> target n/end)
:insert (n/name edge)}
(-> edge
n/from-to
(cond->
(not str?) (j/assoc! :insert " ")))])
-1
(let [^string edge (n/left-edge-with-prefix state parent)
start (n/start (n/with-prefix parent))]
(prn :parent (n/string state parent) :str str?)
[(cond-> {:from start
:to (+ start (count edge))
#_#_:insert " "}
(not str?) (j/assoc! :insert " "))
{:from (n/start target)
:insert edge}]))}))))))))
#js [(cond-> #js {:from start
:to (+ start (count edge))}
(not str?) (j/assoc! :insert " "))
#js {:from (n/start target)
:insert edge}]))}))))))))

(defn barf [direction]
(fn [^js state]
Expand Down
11 changes: 6 additions & 5 deletions test/nextjournal/scratch.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
[nextjournal.clojure-mode.extensions.eval-region :as eval-region]
[nextjournal.clojure-mode.test-utils :as test-utils]))

(def extensions
(.concat cm-clojure/default-extensions (eval-region/extension #js {})))
(comment
(def extensions
(.concat cm-clojure/default-extensions (eval-region/extension #js {})))

(def apply-f (partial test-utils/apply-f extensions))
(def apply-f (partial test-utils/apply-f extensions))

(js/console.log "a ;; hello\n(|)")
(js/console.log (apply-f (commands/slurp -1) "a ;; hello\n(|)"))
(js/console.log "a ;; hello\n(|)")
(js/console.log (apply-f (commands/slurp -1) "a ;; hello\n(|)")))

8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1176,10 +1176,10 @@ source-map@^0.5.6:
resolved "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz"
integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=

[email protected].105:
version "0.7.105"
resolved "https://registry.yarnpkg.com/squint-cljs/-/squint-cljs-0.7.105.tgz#848a588aaf5d19593b2d8b24bad026382435a4ff"
integrity sha512-YtnPewo1ZM5p9kaC6j/rNw4F/FzsLaAS61Vhikw6z6dRJvns/Y/3rwGcb8BCoD6Abx23/frlk0B4/xhedgCbUw==
[email protected].111:
version "0.7.111"
resolved "https://registry.yarnpkg.com/squint-cljs/-/squint-cljs-0.7.111.tgz#1441933ed7162d5590570875394c12b181db9427"
integrity sha512-BZSq3OxqdRN1xpIYBOWDI03tppaOLxtmapUDsS32ViKg2anu6fo44qh3qGAvXcapDwc1mkIS6A2y2GA+SgB2Rw==
dependencies:
chokidar "^3.5.3"

Expand Down

0 comments on commit b4105f4

Please sign in to comment.