Skip to content

Commit

Permalink
Addendum for #49 (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Apr 17, 2024
1 parent 16f0b6c commit b975d8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
(= \\ (.. state -doc (slice (max 0 (dec pos)) pos) toString)))

(defn backspace-backoff [state from to]
#_(js/console.log (some-> (n/|node state from) (u/guard n/line-comment?)))
(if
;; handle line-comments (backspace should not drag forms up into line comments)
(and
;; we are directly in front of a line-comment
;; we are directly in right of a line-comment
(some-> (n/node| state (dec from)) (u/guard n/line-comment?))
;; current line is blank
(not (str/blank? (u/line-content-at state from))))
;; current line is blank or we're left of a line-comment
(not (or (str/blank? (u/line-content-at state from))
(some-> (n/|node state from) (u/guard n/line-comment?)))))
{:cursor (dec from)}
(u/deletion from to)))

Expand Down
3 changes: 1 addition & 2 deletions test/nextjournal/clojure_mode_tests.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@
"\"[|]\"" "\"|]\"" ;; normal deletion inside strings
"( ;;\n|)" "( ;;|\n)" ;; don't put paren behind line comment
"( ;|\n)" "( |\n)"
"(;;\n|;;\n)" "(;;|\n;;\n)"
))
"(;;\n|;;\n)" "(;;|;;\n)"))

#?(:squint nil
:cljs (testing "handle backspace (embedded)"
Expand Down

0 comments on commit b975d8c

Please sign in to comment.