GNU bug report logs - #78680
typescript-ts-mode "fills" code when using (fill-paragraph)

Previous Next

Package: emacs;

Reported by: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>

Date: Tue, 3 Jun 2025 13:42:04 UTC

Severity: normal

Fixed in version 31.0.50

Done: Juri Linkov <juri <at> linkov.net>

To reply to this bug, email your comments to 78680 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#78680; Package emacs. (Tue, 03 Jun 2025 13:42:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Konstantin Kharlamov <Hi-Angel <at> yandex.ru>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 03 Jun 2025 13:42:06 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: typescript-ts-mode "fills" code when using (fill-paragraph)
Date: Tue, 03 Jun 2025 16:41:26 +0300
[Message part 1 (text/plain, inline)]
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.
[1.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78680; Package emacs. (Tue, 03 Jun 2025 16:49:02 GMT) Full text and rfc822 format available.

Message #8 received at 78680 <at> debbugs.gnu.org (full text, mbox):

From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
To: Juri Linkov <juri <at> linkov.net>
Cc: 78680 <at> debbugs.gnu.org
Subject: Re: bug#78680: typescript-ts-mode "fills" code when using
 (fill-paragraph)
Date: Tue, 03 Jun 2025 19:14:01 +0300
On Tue, 2025-06-03 at 18:41 +0300, Juri Linkov wrote:
> 'c-ts-common-comment-setup' is a too confusing name.
> It does more than just setting comment-related variables.
> So 8bccccedb65a should have retained 'c-ts-common-comment-setup'.
> Therefore I restored it in js-ts-mode and typescript-ts-base-mode.

So you did exactly same thing as my patch, but instead of applying mine
to account for contribution since I researched the problem and wrote
the code, you just wrote same thing yourself. This is not fair.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78680; Package emacs. (Tue, 03 Jun 2025 16:51:02 GMT) Full text and rfc822 format available.

Message #11 received at 78680 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
Cc: 78680 <at> debbugs.gnu.org
Subject: Re: bug#78680: typescript-ts-mode "fills" code when using
 (fill-paragraph)
Date: Tue, 03 Jun 2025 18:41:35 +0300
close 78680 31.0.50
thanks

> 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.

'c-ts-common-comment-setup' is a too confusing name.
It does more than just setting comment-related variables.
So 8bccccedb65a should have retained 'c-ts-common-comment-setup'.
Therefore I restored it in js-ts-mode and typescript-ts-base-mode.




bug marked as fixed in version 31.0.50, send any further explanations to 78680 <at> debbugs.gnu.org and Konstantin Kharlamov <Hi-Angel <at> yandex.ru> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Tue, 03 Jun 2025 16:51:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78680; Package emacs. (Wed, 04 Jun 2025 06:16:03 GMT) Full text and rfc822 format available.

Message #16 received at 78680 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
Cc: 78680 <at> debbugs.gnu.org
Subject: Re: bug#78680: typescript-ts-mode "fills" code when using
 (fill-paragraph)
Date: Wed, 04 Jun 2025 09:10:13 +0300
>> 'c-ts-common-comment-setup' is a too confusing name.
>> It does more than just setting comment-related variables.
>> So 8bccccedb65a should have retained 'c-ts-common-comment-setup'.
>> Therefore I restored it in js-ts-mode and typescript-ts-base-mode.
>
> So you did exactly same thing as my patch, but instead of applying mine
> to account for contribution since I researched the problem and wrote
> the code, you just wrote same thing yourself. This is not fair.

Your commit message presented it as a new feature with motivations.  Whereas
I just reverted my recent mistake in two places: not only in typescript-ts-mode,
but also in js-ts-mode.  Thanks for finding this regression!




This bug report was last modified 13 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.