Skip to content

Commit

Permalink
Don't match ns in a string. Fix #3754
Browse files Browse the repository at this point in the history
  • Loading branch information
a13 committed Nov 8, 2024
1 parent c7bed56 commit 02d25d1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## master (unreleased)

### Changes

- [#3754](https://github.com/clojure-emacs/cider/issues/3754): Fix regex in `cider-ns-from-p`.
- [#3753](https://github.com/clojure-emacs/cider/pull/3753): Add `cider-log-show-frameworks` command to show available log frameworks in a buffer.
- [#3746](https://github.com/clojure-emacs/cider/issues/3746): Bring back `cider` completion style for activating backend-driven completion.

Expand Down
2 changes: 1 addition & 1 deletion cider-client.el
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ EVAL-BUFFER is the buffer where the spinner was started."
;;; Evaluation helpers
(defun cider-ns-form-p (form)
"Check if FORM is an ns form."
(string-match-p "^[[:space:]]*\(ns\\([[:space:]]*$\\|[[:space:]]+\\)" form))
(string-match-p "\\`[[:space:]]*\(ns\\([[:space:]]*$\\|[[:space:]]+\\)" form))

(defun cider-ns-from-form (ns-form)
"Get ns substring from NS-FORM."
Expand Down
11 changes: 11 additions & 0 deletions test/cider-client-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@
(expect (cider-ensure-op-supported "foo")
:to-throw 'user-error)))

(describe "cider-ns-form-p"
(it "doesn't match ns in a string"
(let ((ns-in-string "\"\n(ns bar)\n\""))
(expect (cider-ns-form-p ns-in-string) :to-equal nil)))
(it "matches ns"
(let ((ns "(ns bar)\n"))
(expect (cider-ns-form-p ns) :to-equal 0)))
(it "matches ns with leading spaces"
(let ((ns " (ns bar)\n"))
(expect (cider-ns-form-p ns) :to-equal 0))))

(describe "cider-expected-ns"
(before-each
(spy-on 'cider-connected-p :and-return-value t)
Expand Down

0 comments on commit 02d25d1

Please sign in to comment.