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

How should we handle indentation inside strings? #47

Open
lddubeau opened this issue Aug 17, 2017 · 1 comment
Open

How should we handle indentation inside strings? #47

lddubeau opened this issue Aug 17, 2017 · 1 comment

Comments

@lddubeau
Copy link
Collaborator

The mode currently operates so that

const x = `abc
    def`;

Will be indented to:

const x = `abc
def`;

However, tide-format leaves it as in the first snippet.

It is possible to do this as a workaround:

const x = `abc
\    def`;

The escaped space is treated as a space, and typescript-mode won't try to remove the spaces, but yuck!

I'm thinking of modifying the indentation code so that typescript-mode leaves the leading space in lines of multiline strings like the one above intact. I'm wondering though whether this should be configurable. If I just "fix" it, that's going to change the previous behavior that some people may rely on. (That behavior appears flat out bad to me, so I don't know why anyone would rely on that behavior, but maybe I'm missing something.)

@josteink
Copy link
Member

Making more things configurable just gives us a bigger state-space which we will need to manage and handle. And there in lies bugs.

I say make it format things like tsserver does and don't bother adding a bunch of new configuration options.

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

2 participants