Skip to content

Addendum for #49 #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading