Skip to content

Commit aae566e

Browse files
authored
Fix infinite loop when reverse searching for next definition (#624)
Fixes #595 Fixes #612
1 parent 17ecddb commit aae566e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

clojure-mode-syntax-test.el

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,37 @@
6060
(expect (non-func "^hint " form) :to-be nil)
6161
(expect (non-func "#macro " form) :to-be nil))))
6262

63+
(describe "clojure-match-next-def"
64+
(let ((some-sexp "\n(list [1 2 3])"))
65+
(it "handles vars with metadata"
66+
(dolist (form '("(def ^Integer a 1)"
67+
"(def ^:a a 1)"
68+
"(def ^::a a 1)"
69+
"(def ^::a/b a 1)"
70+
"(def ^{:macro true} a 1)"))
71+
(with-clojure-buffer (concat form some-sexp)
72+
(end-of-buffer)
73+
(clojure-match-next-def)
74+
(expect (looking-at "(def")))))
75+
76+
(it "handles vars without metadata"
77+
(with-clojure-buffer (concat "(def a 1)" some-sexp)
78+
(end-of-buffer)
79+
(clojure-match-next-def)
80+
(expect (looking-at "(def"))))
81+
82+
(it "handles invalid def forms"
83+
(dolist (form '("(def ^Integer)"
84+
"(def)"
85+
"(def ^{:macro})"
86+
"(def ^{:macro true})"
87+
"(def ^{:macro true} foo)"
88+
"(def ^{:macro} foo)"))
89+
(with-clojure-buffer (concat form some-sexp)
90+
(end-of-buffer)
91+
(clojure-match-next-def)
92+
(expect (looking-at "(def")))))))
93+
6394
(describe "clojure syntax"
6495
(it "handles prefixed symbols"
6596
(dolist (form '(("#?@aaa" . "aaa")

0 commit comments

Comments
 (0)