Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
- [#168](https://github.com/clojure-emacs/clojure-ts-mode/pull/168): Indent docstrings like `clojure-mode`, moving the lines indented less than `clojure-ts-docstring-fill-prefix-width` to that column and keeping deeper ones, instead of leaving them alone with `clojure-ts-use-markdown-inline` and flattening them without it.
- [#174](https://github.com/clojure-emacs/clojure-ts-mode/pull/174): Speed up indentation of forms with many children, like a big `comment` form, which slowed down with the cube of their length.
- [#175](https://github.com/clojure-emacs/clojure-ts-mode/pull/175): Fix `clojure-ts-align` signalling `treesit-node-outdated` on a line that ends in a form after metadata and more than one space.
- [#176](https://github.com/clojure-emacs/clojure-ts-mode/pull/176): Fix `clojure-ts-align` signalling an invalid search bound when a comment ends the last line before a blank one, and aligning a binding with metadata after a line comment to the metadata alone.

## 0.6.0 (2025-12-02)

Expand Down
13 changes: 11 additions & 2 deletions clojure-ts-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1929,8 +1929,17 @@ BOUND bounds the whitespace search."
(progn
(search-forward-regexp regex bound)
(point))
(when-let* ((cur-sexp (treesit-node-first-child-for-pos
(funcall root-node-fn) (point) t)))
(when-let* ((cur-sexp (let ((node (treesit-node-first-child-for-pos
(funcall root-node-fn) (point) t)))
;; Comments aren't forms to align. A comment
;; at the end of a line takes its newline, so
;; the search starts in one when
;; `align-region' steps back to the end of
;; the line.
(while (and node (string= (treesit-node-type node)
"comment"))
(setq node (treesit-node-next-sibling node t)))
node)))
(goto-char (treesit-node-start cur-sexp))
(if (clojure-ts--metadata-node-p cur-sexp)
(progn
Expand Down
21 changes: 21 additions & 0 deletions test/clojure-ts-mode-indentation-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,27 @@ c)
aa); comment
:aa 2)")

(when-aligning-it "should handle a margin comment before a blank line at the end"
"
{:a 1 ;; comment

}"

"
(are [x y]
(= x y)
1 2 ;; one
3 4 ;; three

)")

(when-aligning-it "should align a binding with metadata after a line comment"
"
(let [a 1
;; comment
^String string 2]
a)")

(when-aligning-it "should work correctly when there are discard forms"
"{:map \"with\"
:some #_\"ignored\" \"form\"}"
Expand Down
Loading