Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't indent multiple variable declarations #40

Open
raxod502 opened this issue Jun 8, 2017 · 5 comments
Open

Doesn't indent multiple variable declarations #40

raxod502 opened this issue Jun 8, 2017 · 5 comments

Comments

@raxod502
Copy link

raxod502 commented Jun 8, 2017

typescript.el indents like this:

var x = 5,
y = 6;

I posit that it should indent like this:

var x = 5,
    y = 6;
@josteink
Copy link
Member

josteink commented Jun 9, 2017

I posit that it should indent like this

As far as Typescript goes, there's just one canonical answer to how things should be: However tsserver formats it.

And lucky for you, tsserver agrees :)

The good news/workaround: If you use typescript-mode with tide, it will use tsserver to reformat the document on each save, giving you the correct formatting.

It would of course be nice if we could make typescript-mode also indent like this out of the box. If anyone feels like making a PR which fixes this, I'll be happy to review.

@dgillis
Copy link

dgillis commented Nov 3, 2017

Have at look at that pull request. It does not handle the case of multiline destructuring assignments. E.g., I think they ought to be indented like this:

var a = 1,
      {x,
       y,
       z} = object;

But typescript mode is still aligning the continuations with the opening brace:

var a = 1,
      {x,
      y,
      z} = object;

I have been using advice that fixes both cases. However there are a lot more edge cases to destructuring that I'm probably ignoring so I excluded.

I notice that typescript mode does correctly indent multiline desctructuring statements when they are on their own. So it would probably not be too difficult to generalize that in a way that it just gives the correct offset relative to the opening of the destructure (which could then be added to the normal multiline to get the proper indentation).

@rhz
Copy link

rhz commented Mar 6, 2019

What is the state of this issue? It would be really cool if typescript-mode would indent multiple variable declarations as in the opening comment, even if it doesn't get destructuring statements right in all edge cases.

@lddubeau
Copy link
Collaborator

lddubeau commented Mar 6, 2019

@rhz PR #56 was the only attempt at fixing the issue, and it died on the vine. Whoever wants to see this resolved should take a look at that PR and the comments on it and build from that to submit a new PR.

@rhz
Copy link

rhz commented Mar 6, 2019

@lddubeau I do not have the skills required nor any familiarity with the codebase to be able to do that. I just wanted to open an issue with a feature request and realised it existed already, so I popped in to see if there were still plans of adding this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants