Skip to content

Commit

Permalink
Don't match ns in a string. Fix clojure-emacs#3754
Browse files Browse the repository at this point in the history
  • Loading branch information
a13 committed Nov 8, 2024
1 parent c7bed56 commit 7094b4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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 7094b4c

Please sign in to comment.