From 145ca14eb576d0f051938e371b6eeaf532d078f6 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 15 Apr 2024 16:10:15 +0200 Subject: [PATCH] Fix #49: bug with hitting backspace after line comment --- CHANGELOG.md | 5 +++++ .../clojure_mode/extensions/close_brackets.cljc | 2 +- src-shared/nextjournal/clojure_mode/util.cljc | 2 +- test/nextjournal/clojure_mode_tests.cljc | 2 ++ yarn.lock | 8 ++++---- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 404ee0d2..6372a950 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Unreleased + +- Bump squint to 0.7.105 +- Fix [#49](https://github.com/nextjournal/clojure-mode/issues/49): bug with hitting backspace after line comment + ## 0.3.1 - Fix [#45](https://github.com/nextjournal/clojure-mode/issues/45): cursor after Discard node should evaluate child diff --git a/src-shared/nextjournal/clojure_mode/extensions/close_brackets.cljc b/src-shared/nextjournal/clojure_mode/extensions/close_brackets.cljc index 8f45608f..9e4a75b5 100644 --- a/src-shared/nextjournal/clojure_mode/extensions/close_brackets.cljc +++ b/src-shared/nextjournal/clojure_mode/extensions/close_brackets.cljc @@ -74,7 +74,7 @@ (j/fn [^:js {:keys [from to head anchor empty]}] (cond (in-string? state from) - (if (= open \") + (if (= \" open) (u/insertion head "\\\"") (u/insertion from to open)) ;; allow typing escaped bracket diff --git a/src-shared/nextjournal/clojure_mode/util.cljc b/src-shared/nextjournal/clojure_mode/util.cljc index 9c74bba3..3bc33059 100644 --- a/src-shared/nextjournal/clojure_mode/util.cljc +++ b/src-shared/nextjournal/clojure_mode/util.cljc @@ -49,7 +49,7 @@ (defn line-content-at [state from] (-> state (j/call-in [:doc :lineAt] from) - (j/call :slice))) + (j/get :text))) (defn map-cursor [^js original-range ^js state update-map] {:pre [(map? update-map)]} diff --git a/test/nextjournal/clojure_mode_tests.cljc b/test/nextjournal/clojure_mode_tests.cljc index 7c68710d..582a7353 100644 --- a/test/nextjournal/clojure_mode_tests.cljc +++ b/test/nextjournal/clojure_mode_tests.cljc @@ -123,6 +123,8 @@ "\"| \"" "\"| \"" ;; do not delete string with whitespace ":x :a |" ":x :a|" ;; do not format on backspace "\"[|]\"" "\"|]\"" ;; normal deletion inside strings + "( ;;\n|)" "( ;;|\n)" ;; don't put paren behind line comment + "( ;|\n)" "( |\n)" )) #?(:squint nil diff --git a/yarn.lock b/yarn.lock index 86e67926..959858cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1176,10 +1176,10 @@ source-map@^0.5.6: resolved "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= -squint-cljs@0.4.81: - version "0.4.81" - resolved "https://registry.yarnpkg.com/squint-cljs/-/squint-cljs-0.4.81.tgz#b1926c112a5caa12ed4ecc6f9035827dc4270bb7" - integrity sha512-ffMxWbL901+xHMlaXeUavfrhK+uX7tsZYzF9/kxJYGZ6+KLOGy1Ke9+osbVNR+Vd/uszX6O/YcpNxCJzThgTUA== +squint-cljs@0.7.105: + version "0.7.105" + resolved "https://registry.yarnpkg.com/squint-cljs/-/squint-cljs-0.7.105.tgz#848a588aaf5d19593b2d8b24bad026382435a4ff" + integrity sha512-YtnPewo1ZM5p9kaC6j/rNw4F/FzsLaAS61Vhikw6z6dRJvns/Y/3rwGcb8BCoD6Abx23/frlk0B4/xhedgCbUw== dependencies: chokidar "^3.5.3"