Subject: tsx-ts-mode: fill-paragraph doesn't work for doc-comments

From: Konstantin Kharlamov <[email-masked]>
Date: Fri, 11 Apr 2025 11:10:34 +0300

Steps to reproduce:

1. Open `test.tsx` with the following content:

    // File description
    /**
     * Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis.
     */
2. Try to "fill" the Lorem ipsum text.

Result: nothing changes, the text doesn't get "filled".

---------

I dug into it, the bug resides in the following condition in
`c-ts-common--fill-paragraph`:

                …
                ;; In rust, NODE will be the body of a comment, and the
                ;; parent will be the whole comment.
                (if-let* ((start (treesit-node-start
                                  (treesit-node-parent node))))
                    (save-excursion
                      (goto-char start)
                      (looking-at "//"))))
                …

The problem is that "(treesit-node-start (treesit-node-parent node))" returns 1.
That happens disregarding the amount of code between the "// File description"
line and where "/* Lorem ipsum…" is. In the actual code there's 51 lines in
between.

Why treesit-node-start does that I don't know, so I decided to report it.