GNU bug report logs - #77803
tsx-ts-mode: wrong indentation for variables declarations

Previous Next

Package: emacs;

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

Date: Mon, 14 Apr 2025 15:43:01 UTC

Severity: normal

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

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Yuan Fu <casouri <at> gmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#77803: closed (tsx-ts-mode: wrong indentation for variables
 declarations)
Date: Fri, 18 Apr 2025 23:44:04 +0000
[Message part 1 (text/plain, inline)]
Your message dated Fri, 18 Apr 2025 16:43:17 -0700
with message-id <14A0AFC9-9CB5-4231-BC0F-D4CEAE48EC7B <at> gmail.com>
and subject line Re: bug#77803: [PATCH v2] Don't indent variable names to their declarator expression (bug#77803)
has caused the debbugs.gnu.org bug report #77803,
regarding tsx-ts-mode: wrong indentation for variables declarations
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
77803: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=77803
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
To: bug-gnu-emacs <at> gnu.org
Subject: tsx-ts-mode: wrong indentation for variables declarations
Date: Mon, 14 Apr 2025 18:41:42 +0300
Given this TypeScript snippet:

    const a = 1,
          b = 2;
    var c = 3,
        d = 4;

…both b and d are expected to be indented to `typescript-ts-mode-indent-offset`
(2 by default). This both makes logical sense and is the behavior in another
editor VSCode.

Instead it gets indented to the length of `const` and `var` + space.

I'd note a separate problem: if you have this code:


    const a = 1,
      b = 2,
          c = 3;

…and you try to indent `c`, instead of getting indented to the previous line it
keeps being at "const + space" length.


[Message part 3 (message/rfc822, inline)]
From: Yuan Fu <casouri <at> gmail.com>
To: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
Cc: Eli Zaretskii <eliz <at> gnu.org>, theo <at> thornhill.no, 77803-done <at> debbugs.gnu.org
Subject: Re: bug#77803: [PATCH v2] Don't indent variable names to their
 declarator expression (bug#77803)
Date: Fri, 18 Apr 2025 16:43:17 -0700
[Message part 4 (text/plain, inline)]

> On Apr 15, 2025, at 10:09 PM, Konstantin Kharlamov <Hi-Angel <at> yandex.ru> wrote:
> 
> On Tue, 2025-04-15 at 17:53 +0300, Konstantin Kharlamov wrote:
>> On Tue, 2025-04-15 at 17:42 +0300, Eli Zaretskii wrote:
>>> 
>>> Try
>>>       make -C test lisp/progmodes/typescript-ts-mode-tests
>> 
>> Thank you, please see the patch!
> 
> v2: no code change, just noticed a typo in patch description, a "one
> space" instead of "two spaces" after the dot, and a missing dot in the
> final sentence: fixed.
[1.patch (text/x-patch, attachment)]
[Message part 6 (text/plain, inline)]
Thanks! I personally like the current indentation, but indeed other editors, and more importantly prettier, indents like what your patch implemented. I applied the patch to emacs-30 and pushed.

Yuan

This bug report was last modified 73 days ago.

Previous Next


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