Skip to content

Commit 78b9147

Browse files
authored
[Fix 2937] Fix cider-last-sexp bounds on whitespaces after sexp (#2976)
Evaluating cider-last-sexp includes whitespaces and the first newline after such sexp, which causes some weird behaviours evaluating code (see #2937).
1 parent e38abb4 commit 78b9147

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
* [#2941](https://github.com/clojure-emacs/cider/issues/2941): Use main args in alias for clojure cli
1212
* [#2953](https://github.com/clojure-emacs/cider/issues/2953): Don't font-lock function/macro vars as vars.
1313
* [#2964](https://github.com/clojure-emacs/cider/issues/2964): Fixes issue with `cider-company-enable-fuzzy-completion` and Helm
14+
* [#2937](https://github.com/clojure-emacs/cider/issues/2937): Green fringe produced for extra line in rich comment block
1415

1516
### Changes
1617

1718
* Removed `cider-clojure-cli-parameters` due to clojure-cli jack-in changes
1819
* Bump the injected `cider-nrepl` to 0.25.6. This should fix a compatibility issue with Java 15 and fetching fresh ClojureDocs data.
20+
* Changed the behaviour of `cider-last-sexp` so it returns only the sexp, excluding all whitespace and/or the first newline after.
1921

2022
## 1.0.0 (2020-28-12)
2123

cider-util.el

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ instead."
193193
(clojure-backward-logical-sexp 1)
194194
(list (point)
195195
(progn (clojure-forward-logical-sexp 1)
196-
(skip-chars-forward "[:blank:]")
197-
(when (looking-at-p "\n") (forward-char 1))
198196
(point))))))
199197

200198
(defun cider-start-of-next-sexp (&optional skip)

test/cider-util-tests.el

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,23 @@ buffer."
213213
(insert "'")
214214
(expect (cider-sexp-at-point 'bounds) :to-equal '(5 15))))))
215215

216+
(describe "cider-last-sexp"
217+
(describe "when the param 'bounds is not given"
218+
(it "returns the last sexp"
219+
(with-clojure-buffer "a\n\n(defn ...)|\n\nb"
220+
(expect (cider-last-sexp) :to-equal "(defn ...)")))
221+
(it "returns the last sexp event when there are whitespaces"
222+
(with-clojure-buffer "a\n\n(defn ...) ,\n|\nb"
223+
(expect (cider-last-sexp) :to-equal "(defn ...)"))))
224+
225+
(describe "when the param 'bounds is given"
226+
(it "returns the bounds of last sexp"
227+
(with-clojure-buffer "a\n\n(defn ...)|\n\nb"
228+
(expect (cider-last-sexp 'bounds) :to-equal '(4 14))))
229+
(it "returns the bounds of last sexp event when there are whitespaces"
230+
(with-clojure-buffer "a\n\n(defn ...) ,\n|\nb"
231+
(expect (cider-last-sexp 'bounds) :to-equal '(4 14))))))
232+
216233
(describe "cider-defun-at-point"
217234
(describe "when the param 'bounds is not given"
218235
(it "returns the defun at point"

0 commit comments

Comments
 (0)