GNU bug report logs - #78187
tsx-ts-mode: wrong indentation of object parameters

Previous Next

Package: emacs;

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

Date: Thu, 1 May 2025 12:57:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>, Yuan Fu <casouri <at> gmail.com>
Cc: 78187 <at> debbugs.gnu.org
Subject: bug#78187: tsx-ts-mode: wrong indentation of object parameters
Date: Sat, 10 May 2025 13:17:26 +0300
> From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
> Date: Thu, 01 May 2025 19:56:12 +0700
> 
> Given this snippet indented as expected:
> 
>     interface iface { f1: string,
>                       f2: string
>     }
> 
> indenting `f2` gives:
> 
>     interface iface { f1: string,
>       f2: string
>     }
> 
> May not be the best example, but JavaScript/TypeScript are heavy users of curly braces, and sometimes I do want to write the first field on the line with opening curly brace, which usually implies aligning other fields to it.
> 
> ---------
> 
> I spent quite some time trying to write a patch for this, but I am at loss. The closest I come to a solution is a rule:
> 
>     ((node-is "property_signature") prev-sibling 0)
> 
> it works correctly for every param starting with 2nd, but it misindents the 1st parameter. Probably some condition required like "for the 1st parameter do the offset, for consequent ones follow previous siblings indentation". But I have no idea how to do that.
> 
> I looked at `c++-ts-mode` (which does it right) for inspiration, but couldn't figure out what it does in the same situation.

Yuan, any comments?




This bug report was last modified 32 days ago.

Previous Next


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