Skip to content

Commit 8f58807

Browse files
mknextjournal-ci
authored andcommitted
cm6: make eval-region/node-at-cursor also recognize node before cursor
* Make eval-region/node-at-cursor also recognize node before cursor Makes it consider the form before also when there's whitespace or a newline between it and the cursor position.
1 parent 1056e50 commit 8f58807

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/nextjournal/clojure_mode/extensions/eval_region.cljs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@
2626
([state] (node-at-cursor state (j/get (primary-selection state) :from)))
2727
([^js state from]
2828
(some->> (n/nearest-touching state from -1)
29-
(#(when (and (or (n/terminal-type? (n/type %))
30-
(= (n/start %) from)
31-
(= (n/end %) from))
32-
(not (n/top? %))) %))
29+
(#(when (or (n/terminal-type? (n/type %))
30+
(<= (n/start %) from)
31+
(<= (n/end %) from))
32+
(cond-> %
33+
(or (n/top? %)
34+
(and (not (n/terminal-type? (n/type %)))
35+
(< (n/start %) from (n/end %))))
36+
(-> (n/children from -1) first))))
3337
(uppermost-edge-here from)
3438
(n/balanced-range state))))
3539

0 commit comments

Comments
 (0)