diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d4c41387..992e2772e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/cider-client.el b/cider-client.el index 0ae4025bd..26b222998 100644 --- a/cider-client.el +++ b/cider-client.el @@ -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." diff --git a/test/cider-client-tests.el b/test/cider-client-tests.el index 99516cdd0..7fbf8360c 100644 --- a/test/cider-client-tests.el +++ b/test/cider-client-tests.el @@ -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)