Subject: Re: bug#77803: [PATCH v2] Don't indent variable names to their declarator expression (bug#77803)

From: Konstantin Kharlamov <[email-masked]>
Date: Sun, 20 Apr 2025 01:58:56 +0300

On Sat, 2025-04-19 at 16:31 +0300, Dmitry Gutov wrote:
> On 19/04/2025 08:46, Konstantin Kharlamov wrote:
> > On Sat, 2025-04-19 at 04:02 +0300, Dmitry Gutov wrote:
> > > On 19/04/2025 02:43, Yuan Fu wrote:
> > > > Thanks! I personally like the current indentation,
> > > js2-mode has been doing it this way for a number of years
> > > (triggered
> > > by
> > > user requests), js-mode followed suit later.
> > That's unusual, do you have a link to the discussion? Such
> > indentation
> > doesn't make sense to me (because when you have "const" and "var"
> > declarations near, they won't be aligned); and when I test it in
> > VSCode
> > which I think most Web devs are using, it indents both to 3 spaces.
> 
> https://github.com/mooz/js2-mode/issues/1 is when it was added, then
> see 
> other reports in the tracker about refining it and adding support for
> different cases.

Oooh… it seems to be a misunderstanding. The user wasn't asking to
indent every declaration to the declarator (as it was in ts-tsx-mode
and as it seems now in jsx-mode). The user pointed out the indentation
wasn't working at all, and showed "expected indentation", where there
are 4 spaces used; however it is an accident that 4 spaces are equal to
"var" + space.

If you test VSCode with JS file, you'll see it too indents them to 4
spaces, i.e. "var" + space… However, if you replace `var` with `const`,
VSCode will still use same indentation, it won't try to indent to
"`const` + space". Which makes sense.

I see that it is easy to misinterpret the OP's example as an ask to
indent variables to the declarator, unfortunately I don't think that
was something the issue author was asking for.