Subject: typescript-ts-mode "fills" code when using (fill-paragraph)

From: Konstantin Kharlamov <[email-masked]>
Date: Tue, 03 Jun 2025 16:41:26 +0300

This is on latest master (50e3bce315e). To reproduce:

1. Create test.ts with this content:

	// test
	console.log("hello world")

2. Open as `emacs -Q test.ts`
3. Evaluate (progn (require 'treesit) (typescript-ts-mode))
4. Put caret at the word `test1`
5. Press M-q

Expected: nothing.
Actual: the code gets moved into the comment

-------------

I investigated the problem, it seems to be because `fill-comment-
function` is nil. From my understanding, it's supposed to be set by
invoking a common helper (c-ts-common-comment-setup), which I
implemented in the attached patch.

I am testing this to make sure there wouldn't be any adverse effects.

What's odd is that I don't seem to remember having this problem before,
and; and as a matter of fact we even have investigated a bug #77727
which wouldn't be possible with this issue. Seems like a regression.
From 869d0b95bd49ded2c66222d6b8ad02416ca1f465 Mon Sep 17 00:00:00 2001
From: Konstantin Kharlamov <[email-masked]>
Date: Tue, 3 Jun 2025 16:32:14 +0300
Subject: [PATCH] Set up c-like commentary helpers for typescript-ts modes

Currently, running (fill-paragraph) over typescript comment next to a
code may result in the code being stuffed into the comment.  This is
because fill-paragraph-function isn't set.  Fix that by invoking
`(c-ts-common-comment-setup)', similarly to other c-like modes.

* (typescript-ts-base-mode): Invoke `(c-ts-common-comment-setup)'.
---
 lisp/progmodes/typescript-ts-mode.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
index 0bc629cc81e..10be02b9995 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -661,6 +661,7 @@ typescript-ts-base-mode
   :syntax-table typescript-ts-mode--syntax-table
 
   ;; Comments.
+  (c-ts-common-comment-setup)
   (setq-local comment-setup-function #'js--treesit-comment-setup)
 
   ;; Electric
-- 
2.49.0