Skip to content

Commit c228dec

Browse files
authored
[Fix #3754] Don't match ns in a string
1 parent 9f2d715 commit c228dec

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## master (unreleased)
44

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

cider-client.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ EVAL-BUFFER is the buffer where the spinner was started."
108108
;;; Evaluation helpers
109109
(defun cider-ns-form-p (form)
110110
"Check if FORM is an ns form."
111-
(string-match-p "^[[:space:]]*\(ns\\([[:space:]]*$\\|[[:space:]]+\\)" form))
111+
(string-match-p "\\`[[:space:]]*\(ns\\([[:space:]]*$\\|[[:space:]]+\\)" form))
112112

113113
(defun cider-ns-from-form (ns-form)
114114
"Get ns substring from NS-FORM."

test/cider-client-tests.el

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,17 @@
132132
(expect (cider-ensure-op-supported "foo")
133133
:to-throw 'user-error)))
134134

135+
(describe "cider-ns-form-p"
136+
(it "doesn't match ns in a string"
137+
(let ((ns-in-string "\"\n(ns bar)\n\""))
138+
(expect (cider-ns-form-p ns-in-string) :to-equal nil)))
139+
(it "matches ns"
140+
(let ((ns "(ns bar)\n"))
141+
(expect (cider-ns-form-p ns) :to-equal 0)))
142+
(it "matches ns with leading spaces"
143+
(let ((ns " (ns bar)\n"))
144+
(expect (cider-ns-form-p ns) :to-equal 0))))
145+
135146
(describe "cider-expected-ns"
136147
(before-each
137148
(spy-on 'cider-connected-p :and-return-value t)

0 commit comments

Comments
 (0)