Skip to content

Commit 5edf40f

Browse files
committed
Fix indentation sample and add indentation integration test
Fix the defonce form indentation (2-space body indent per :inner 0 rule) and a docstring continuation line alignment. Remove the NOTE comment about known misindentation. Add an integration test that re-indents the entire indentation.clj sample and asserts the result matches the original, catching any indentation regressions across the full file.
1 parent 45cf2fb commit 5edf40f

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

test/clojure-ts-mode-integration-test.el

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@
2929
(require 'imenu)
3030
(require 'test-helper "test/test-helper")
3131

32+
(describe "integration: indentation"
33+
(before-all
34+
(unless (treesit-language-available-p 'clojure)
35+
(signal 'buttercup-pending "tree-sitter Clojure grammar not available")))
36+
37+
(it "preserves correct indentation of indentation.clj after indent-region"
38+
(let* ((file (clojure-ts-test--resource-file "indentation.clj"))
39+
(original (with-temp-buffer
40+
(insert-file-contents file)
41+
(buffer-string))))
42+
(with-temp-buffer
43+
(insert original)
44+
(clojure-ts-mode)
45+
(indent-region (point-min) (point-max))
46+
(expect (buffer-string) :to-equal original)))))
47+
3248
(describe "integration: font-lock on sample files"
3349
(before-all
3450
(unless (treesit-language-available-p 'clojure)

test/samples/indentation.clj

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,14 @@
251251

252252
;; A few examples from clojure core.
253253

254-
;; NOTE: This one is not indented correctly, I'm keeping it here as a reminder
255-
;; to fix it later.
256254
(defonce ^:dynamic
257-
^{:private true
258-
:doc "A ref to a sorted set of symbols representing loaded libs"}
259-
*loaded-libs* (ref (sorted-set)))
255+
^{:private true
256+
:doc "A ref to a sorted set of symbols representing loaded libs"}
257+
*loaded-libs* (ref (sorted-set)))
260258

261259
(defn index-of
262260
"Return index of value (string or char) in s, optionally searching
263-
forward from from-index. Return nil if value not found."
261+
forward from from-index. Return nil if value not found."
264262
{:added "1.8"}
265263
([^CharSequence s value]
266264
(let [result ^long

0 commit comments

Comments
 (0)