Skip to content

Commit

Permalink
wipper
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Jun 10, 2024
1 parent db329b3 commit 4e5f8dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src-shared/nextjournal/clojure_mode/commands.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}]))}))))))))
Expand Down
3 changes: 3 additions & 0 deletions test/nextjournal/clojure_mode_tests.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/nextjournal/scratch.cljs
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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(|)"))

0 comments on commit 4e5f8dd

Please sign in to comment.