GNU bug report logs - #78121
tsx-ts-mode: wrong indentation of body with misindented args

Previous Next

Package: emacs;

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

Date: Mon, 28 Apr 2025 16:17:05 UTC

Severity: normal

Done: Yuan Fu <casouri <at> gmail.com>

To reply to this bug, email your comments to 78121 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#78121; Package emacs. (Mon, 28 Apr 2025 16:17:06 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. (Mon, 28 Apr 2025 16:17: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: tsx-ts-mode: wrong indentation of body with misindented args
Date: Mon, 28 Apr 2025 23:15:35 +0700
Given this TypeScript:

    const updatePage = (a1: string,
                        a2: number) => {
      return true;
    }

upon attempting to indent the `return true;` line it becomes indented as:

    const updatePage = (a1: string,
                        a2: number) => {
                          return true;
    }

which isn't expected.

P.S.: I'd note separately that a2 gets indented to 2 spaces, which even though goes in line with VSCode, I am not sure if it's useful. Does anybody even indent the second param to "2 spaces" when 1st param resides much further align-wise? C and C++ modes align 2-nd param to the 1st one, python-mode does too. Should perhaps tsx-ts-mode handle that similarly as well?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78121; Package emacs. (Tue, 29 Apr 2025 15:22:02 GMT) Full text and rfc822 format available.

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

From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
To: 78121 <at> debbugs.gnu.org
Subject: bug#78121: tsx-ts-mode: wrong indentation of body with misindented
 args
Date: Tue, 29 Apr 2025 22:21:37 +0700
[Message part 1 (text/plain, inline)]
I wrote a fix and added a test, please review.

I did not touch the situation discussed in P.S. (should I maybe create
a separate issue for that?), this only fixes the problem reported.
[1.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78121; Package emacs. (Tue, 29 Apr 2025 15:39:03 GMT) Full text and rfc822 format available.

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

From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
To: 78121 <at> debbugs.gnu.org
Subject: Re: bug#78121: tsx-ts-mode: wrong indentation of body with
 misindented args
Date: Tue, 29 Apr 2025 22:38:31 +0700
[Message part 1 (text/plain, inline)]
On Tue, 2025-04-29 at 22:21 +0700, Konstantin Kharlamov wrote:
> I wrote a fix and added a test, please review.
> 
> I did not touch the situation discussed in P.S. (should I maybe
> create
> a separate issue for that?), this only fixes the problem reported.

v2: improved the test to cover potential edge case, clarified
description.
[1.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78121; Package emacs. (Tue, 29 Apr 2025 18:11:02 GMT) Full text and rfc822 format available.

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

From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
To: 78121 <at> debbugs.gnu.org
Subject: Re: bug#78121: tsx-ts-mode: wrong indentation of body with
 misindented args
Date: Wed, 30 Apr 2025 01:10:39 +0700
[Message part 1 (text/plain, inline)]
On Tue, 2025-04-29 at 22:38 +0700, Konstantin Kharlamov wrote:
> On Tue, 2025-04-29 at 22:21 +0700, Konstantin Kharlamov wrote:
> > I wrote a fix and added a test, please review.
> > 
> > I did not touch the situation discussed in P.S. (should I maybe
> > create
> > a separate issue for that?), this only fixes the problem reported.
> 
> v2: improved the test to cover potential edge case, clarified
> description.

v3: typo in test name
[1.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78121; Package emacs. (Thu, 01 May 2025 07:41:02 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
Cc: 78121 <at> debbugs.gnu.org
Subject: Re: bug#78121: tsx-ts-mode: wrong indentation of body with
 misindented args
Date: Thu, 1 May 2025 00:40:36 -0700
> On Apr 29, 2025, at 11:10 AM, Konstantin Kharlamov <Hi-Angel <at> yandex.ru> wrote:
> 
> On Tue, 2025-04-29 at 22:38 +0700, Konstantin Kharlamov wrote:
>> On Tue, 2025-04-29 at 22:21 +0700, Konstantin Kharlamov wrote:
>>> I wrote a fix and added a test, please review.
>>> 
>>> I did not touch the situation discussed in P.S. (should I maybe
>>> create
>>> a separate issue for that?), this only fixes the problem reported.
>> 
>> v2: improved the test to cover potential edge case, clarified
>> description.
> 
> v3: typo in test name
> <1.patch>

Thank you very much! I see your point. But could you make the test simpler, so it’s easier to see the intent of the test? 

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78121; Package emacs. (Thu, 01 May 2025 07:56:02 GMT) Full text and rfc822 format available.

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

From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 78121 <at> debbugs.gnu.org
Subject: Re: bug#78121: tsx-ts-mode: wrong indentation of body with
 misindented args
Date: Thu, 01 May 2025 14:55:18 +0700
[Message part 1 (text/plain, inline)]
On Thu, 2025-05-01 at 00:40 -0700, Yuan Fu wrote:
> 
> 
> > On Apr 29, 2025, at 11:10 AM, Konstantin Kharlamov
> > <Hi-Angel <at> yandex.ru> wrote:
> > 
> > On Tue, 2025-04-29 at 22:38 +0700, Konstantin Kharlamov wrote:
> > > On Tue, 2025-04-29 at 22:21 +0700, Konstantin Kharlamov wrote:
> > > > I wrote a fix and added a test, please review.
> > > > 
> > > > I did not touch the situation discussed in P.S. (should I maybe
> > > > create
> > > > a separate issue for that?), this only fixes the problem
> > > > reported.
> > > 
> > > v2: improved the test to cover potential edge case, clarified
> > > description.
> > 
> > v3: typo in test name
> > <1.patch>
> 
> Thank you very much! I see your point. But could you make the test
> simpler, so it’s easier to see the intent of the test? 

Sure, which part do you find worth improving?  I did a few amendments
(attached), which might make the test prettier, will be glad to hear if
I can improve it further.  That aside, I am hopeful the test
description provides the information about test purpose.

v4: 1. made parameter names alphabetic (and thus equally sized), 2.
aligned every 2nd param to the 1st one. Initially I avoided this on
purpose, but while writing an email I figured my reasoning missed a
point, aligning them is fine.
[1.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78121; Package emacs. (Thu, 01 May 2025 08:39:01 GMT) Full text and rfc822 format available.

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

From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 78121 <at> debbugs.gnu.org
Subject: Re: bug#78121: tsx-ts-mode: wrong indentation of body with
 misindented args
Date: Thu, 01 May 2025 15:37:48 +0700
On Thu, 2025-05-01 at 14:55 +0700, Konstantin Kharlamov wrote:
> On Thu, 2025-05-01 at 00:40 -0700, Yuan Fu wrote:
> > 
> > 
> > > On Apr 29, 2025, at 11:10 AM, Konstantin Kharlamov
> > > <Hi-Angel <at> yandex.ru> wrote:
> > > 
> > > On Tue, 2025-04-29 at 22:38 +0700, Konstantin Kharlamov wrote:
> > > > On Tue, 2025-04-29 at 22:21 +0700, Konstantin Kharlamov wrote:
> > > > > I wrote a fix and added a test, please review.
> > > > > 
> > > > > I did not touch the situation discussed in P.S. (should I
> > > > > maybe
> > > > > create
> > > > > a separate issue for that?), this only fixes the problem
> > > > > reported.
> > > > 
> > > > v2: improved the test to cover potential edge case, clarified
> > > > description.
> > > 
> > > v3: typo in test name
> > > <1.patch>
> > 
> > Thank you very much! I see your point. But could you make the test
> > simpler, so it’s easier to see the intent of the test? 
> 
> Sure, which part do you find worth improving?  I did a few amendments
> (attached), which might make the test prettier, will be glad to hear
> if
> I can improve it further.  That aside, I am hopeful the test
> description provides the information about test purpose.
> 
> v4: 1. made parameter names alphabetic (and thus equally sized), 2.
> aligned every 2nd param to the 1st one. Initially I avoided this on
> purpose, but while writing an email I figured my reasoning missed a
> point, aligning them is fine.

In case the question is about the function declarations being embedded:
at least f2 is purpose.  f2 tests that if a function is embedded, it
still results in expected indentation. I could move f3 out though, but
this would result in increase of the ELisp that does indentation
(because right now I indent everything up to (point-max), but if I move
f3 out, I'd have to indent two places separately).  That aside, I think
it's also nice to have more tests for embedded functions 😊




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78121; Package emacs. (Sun, 25 May 2025 08:37:01 GMT) Full text and rfc822 format available.

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

From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 78121 <at> debbugs.gnu.org
Subject: Re: bug#78121: tsx-ts-mode: wrong indentation of body with
 misindented args
Date: Sun, 25 May 2025 11:36:31 +0300
[Message part 1 (text/plain, inline)]
v5: I noticed I forgot to add the "*" bullets to the commit message,
fixed.
[1.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78121; Package emacs. (Sun, 25 May 2025 08:56:03 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
Cc: casouri <at> gmail.com, 78121 <at> debbugs.gnu.org
Subject: Re: bug#78121: tsx-ts-mode: wrong indentation of body with misindented
 args
Date: Sun, 25 May 2025 11:55:44 +0300
> Cc: 78121 <at> debbugs.gnu.org
> From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
> Date: Sun, 25 May 2025 11:36:31 +0300
> 
> v5: I noticed I forgot to add the "*" bullets to the commit message,
> fixed.

Thanks, but if we are talking about formatting of the log messages,
then these ones have too long lines.  When we generate ChangeLog files
from Git log, the log messages are indented 8 columns, so the longest
line should be 70 columns, and preferably 63.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78121; Package emacs. (Sun, 25 May 2025 09:04:01 GMT) Full text and rfc822 format available.

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

From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: casouri <at> gmail.com, 78121 <at> debbugs.gnu.org
Subject: Re: bug#78121: tsx-ts-mode: wrong indentation of body with
 misindented args
Date: Sun, 25 May 2025 12:03:20 +0300
[Message part 1 (text/plain, inline)]
On Sun, 2025-05-25 at 11:55 +0300, Eli Zaretskii wrote:
> > Cc: 78121 <at> debbugs.gnu.org
> > From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
> > Date: Sun, 25 May 2025 11:36:31 +0300
> > 
> > v5: I noticed I forgot to add the "*" bullets to the commit
> > message,
> > fixed.
> 
> Thanks, but if we are talking about formatting of the log messages,
> then these ones have too long lines.  When we generate ChangeLog
> files
> from Git log, the log messages are indented 8 columns, so the longest
> line should be 70 columns, and preferably 63.

Thanks, done (v6 attached)!
[1.patch (text/x-patch, attachment)]

Reply sent to Yuan Fu <casouri <at> gmail.com>:
You have taken responsibility. (Mon, 26 May 2025 03:54:01 GMT) Full text and rfc822 format available.

Notification sent to Konstantin Kharlamov <Hi-Angel <at> yandex.ru>:
bug acknowledged by developer. (Mon, 26 May 2025 03:54:02 GMT) Full text and rfc822 format available.

Message #37 received at 78121-done <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 78121-done <at> debbugs.gnu.org
Subject: Re: bug#78121: tsx-ts-mode: wrong indentation of body with
 misindented args
Date: Sun, 25 May 2025 20:53:13 -0700
[Message part 1 (text/plain, inline)]
> On May 25, 2025, at 2:03 AM, Konstantin Kharlamov <Hi-Angel <at> yandex.ru> wrote:
> 
> On Sun, 2025-05-25 at 11:55 +0300, Eli Zaretskii wrote:
>>> Cc: 78121 <at> debbugs.gnu.org
>>> From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
>>> Date: Sun, 25 May 2025 11:36:31 +0300
>>> 
>>> v5: I noticed I forgot to add the "*" bullets to the commit
>>> message,
>>> fixed.
>> 
>> Thanks, but if we are talking about formatting of the log messages,
>> then these ones have too long lines.  When we generate ChangeLog
>> files
>> from Git log, the log messages are indented 8 columns, so the longest
>> line should be 70 columns, and preferably 63.
> 
> Thanks, done (v6 attached)!
[1.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
Thank you! Merged to emacs-30.

Yuan

This bug report was last modified 6 days ago.

Previous Next


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