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: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#76704: closed (30.1; Indentation of braces on separate line
 in js-ts-mode)
Date: Sun, 20 Apr 2025 06:17:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sun, 20 Apr 2025 09:16:02 +0300
with message-id <86jz7f73z1.fsf <at> gnu.org>
and subject line Re: bug#76704: 30.1; Indentation of braces on separate line in js-ts-mode
has caused the debbugs.gnu.org bug report #76704,
regarding 30.1; Indentation of braces on separate line in js-ts-mode
to be marked as done.

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


-- 
76704: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=76704
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Fabian Brosda <f.brosda <at> gmx.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.1; Indentation of braces on separate line in js-ts-mode
Date: Sun, 02 Mar 2025 20:44:39 +0100
Hi,

when using js-ts-mode instead of js-mode, braces, which are put on a
separate line are indented one level too much.  Here is a simple example
of how the indentation looks like, after using indent-region on the
whole function:

```
function test(x)
    {
	    if(x)
	        {
		        return a;
	        }
	    else
	        {
		        return b;
	        }
    }

```

The used tree-sitter grammar is downloaded from
https://github.com/tree-sitter/tree-sitter-javascript.

Having braces on a separate line is probably not the most common for
javascript, but using indent-region in the js-mode, does yield the
expected result.  The js.el file does already contain a comment
mentioning braces in js--treesit-indent-rules.  But even based on the
git history it is not clear to me, what exactly is meant:

```
       ;; "{" on the newline.
       ((node-is "statement_block") parent-bol js-indent-level)
```

Link: https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/js.el#L3457

If I replace 'js-indent-level' with '0' in this line, the indentation would
be correct, but this might have unwanted side-effects I overlooked.

My current emacs version:

GNU Emacs 30.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.48,
cairo version 1.18.2)

Thanks for looking into this.

Fabian


[Message part 3 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: Vincenzo Pupillo <v.pupillo <at> gmail.com>
Cc: f.brosda <at> gmx.de, 76704-done <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#76704: 30.1;
 Indentation of braces on separate line in js-ts-mode
Date: Sun, 20 Apr 2025 09:16:02 +0300
> From: Vincenzo Pupillo <v.pupillo <at> gmail.com>
> Cc: juri <at> linkov.net, f.brosda <at> gmx.de, 76704 <at> debbugs.gnu.org
> Date: Sat, 19 Apr 2025 23:09:32 +0200
> 
> Ciao Eli,
> 
> In data sabato 19 aprile 2025 15:40:31 Ora legale dell’Europa centrale, Eli 
> Zaretskii ha scritto:
> > > From: Vincenzo Pupillo <v.pupillo <at> gmail.com>
> > > Cc: 76704 <at> debbugs.gnu.org
> > > Date: Wed, 02 Apr 2025 23:17:10 +0200
> > > 
> > > Ciao Fabian, I've fixed these two things (I hope!).
> > > 
> > > The new patch is attached.
> > 
> > I wanted to install this, but it no longer applies cleanly.  Could you
> > please rebase on the current master and resubmit?
> Done, the attached patch is rebased against the master.

Thanks, installed on master, and closing the bug.


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.