diff --git a/src-shared/nextjournal/clojure_mode/commands.cljc b/src-shared/nextjournal/clojure_mode/commands.cljc index dc41f85..08cc439 100644 --- a/src-shared/nextjournal/clojure_mode/commands.cljc +++ b/src-shared/nextjournal/clojure_mode/commands.cljc @@ -152,6 +152,7 @@ 1 (some-> % n/with-prefix n/right n/end-edge?) -1 (some-> % n/with-prefix n/left n/start-edge?)))))] (let [str? (n/string? parent)] + (prn :parent (n/string state parent) :str str?) (when-let [target (case direction 1 (first (remove n/line-comment? (n/rights (n/with-prefix parent)))) -1 (first (remove n/line-comment? (n/lefts (n/with-prefix parent)))))] {:cursor/mapped from @@ -163,12 +164,13 @@ (-> edge n/from-to (cond-> - (not str?) (j/assoc! :insert " ")))]) + true #_(not str?) (j/assoc! :insert " ")))]) -1 (let [^string edge (n/left-edge-with-prefix state parent) start (n/start (n/with-prefix parent))] [(cond-> {:from start - :to (+ start (count edge))} + :to (+ start (count edge)) + #_#_:insert " "} (not str?) (j/assoc! :insert " ")) {:from (n/start target) :insert edge}]))})))))))) diff --git a/test/nextjournal/clojure_mode_tests.cljc b/test/nextjournal/clojure_mode_tests.cljc index 0909b3c..35fe066 100644 --- a/test/nextjournal/clojure_mode_tests.cljc +++ b/test/nextjournal/clojure_mode_tests.cljc @@ -8,11 +8,14 @@ [nextjournal.clojure-mode.commands :as commands] [nextjournal.clojure-mode.extensions.formatting :as format] [nextjournal.clojure-mode.extensions.eval-region :as eval-region] + [nextjournal.scratch] #?@(:squint [] :cljs [[nextjournal.livedoc :as livedoc]]) #?(:squint ["assert" :as assert])) #?(:squint (:require-macros [nextjournal.clojure-mode-tests.macros :refer [deftest are testing is]]))) +#_(js/process.exit 0) + (def extensions (.concat cm-clojure/default-extensions (eval-region/extension #js {})) ;; optionally test with live grammar diff --git a/test/nextjournal/scratch.cljs b/test/nextjournal/scratch.cljs index def770a..52c0e8c 100644 --- a/test/nextjournal/scratch.cljs +++ b/test/nextjournal/scratch.cljs @@ -1,4 +1,4 @@ -(ns nextjournal.clojure-mode.scratch +(ns nextjournal.scratch (:require [nextjournal.clojure-mode.commands :as commands] [nextjournal.clojure-mode :as cm-clojure] [nextjournal.clojure-mode.extensions.eval-region :as eval-region] @@ -9,6 +9,6 @@ (def apply-f (partial test-utils/apply-f extensions)) -(js/console.log "\"|\" 1") -(js/console.log (apply-f (commands/slurp 1) "\"|\" 1")) +(js/console.log "a ;; hello\n(|)") +(js/console.log (apply-f (commands/slurp -1) "a ;; hello\n(|)"))