GNU bug report logs - #76704
30.1; Indentation of braces on separate line in js-ts-mode

Previous Next

Package: emacs;

Reported by: Fabian Brosda <f.brosda <at> gmx.de>

Date: Mon, 3 Mar 2025 04:33:03 UTC

Severity: minor

Found in version 30.1

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Vincenzo Pupillo <v.pupillo <at> gmail.com>
To: juri <at> linkov.net, Eli Zaretskii <eliz <at> gnu.org>, Fabian Brosda <f.brosda <at> gmx.de>
Cc: 76704 <at> debbugs.gnu.org
Subject: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode
Date: Tue, 01 Apr 2025 23:04:14 +0200
[Message part 1 (text/plain, inline)]
Ciao Fabian, 
this updated patch fix all yours example and others corner case of arrow 
function, chained member expression. 
For switch body indentation now possible to use js-switch-indent-offset as in 
js-mode. js-chain-indent can be used to achieve the same behavior as js-mode 
for that chained member expression.
Can you please try it again?

Vincenzo

In data venerdì 28 marzo 2025 11:53:49 Ora legale dell’Europa centrale, Fabian 
Brosda ha scritto:
> Hi Vincenzo,
> 
> >> great that there is already an updated patch. I did test it and it looks
> >> good for functions, conditionals, loops.  Regarding arrow functions (or
> >> variable declarations in general), the result is different, then with
> >> js-mode, but personally I think the result looks more consistent in
> >> js-ts-mode.
> > 
> > Could you please show me this difference?
> 
> The examples are not really complex, just a few maybe a bit unusual
> cases I could think of.  You can find the gist containing the js-mode
> and js-ts-mode (including your latest patch) version and a diff here:
> 
> https://gist.github.com/fbrosda/11870561bb009be87b719d5b9a7aa625
> 
> A short summary:
> 
> - Declaring a variable and assigning an arrow function, the braces are
>   not indented in js-ts-mode, but indented to the start of the variable
>   in js-mode (also compare the difference between let and const)
> - Similar cases, when having a line break in a variable declaration.
>   js-ts-mode uses the fixed indentation js-indent-level, while js-mode
>   indents to the start of the variable name.  Observe the difference
>   between const and let. I personally prefer the js-ts-mode, so that
>   const and let, if you mix the two. But at least in my code, this is
>   normally used very rarely, so both versions are fine.
> - switch-cases have a few differences. For switch with the { on a
>   separate line, it is imo wrong in js-mode to indent the case
>   statements, as the blocks inside the case are not further indented.
>   Switches inside a function break in js-ts-mode, as they have a nega
> 
> 
> Hope this helps.
> 
> Fabian

[0001-Fix-indentation-of-when-on-a-new-line-of-a-function-.patch (text/x-patch, attachment)]

This bug report was last modified 90 days ago.

Previous Next


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