typescript.el icon indicating copy to clipboard operation
typescript.el copied to clipboard

How should we handle indentation inside strings?

Open lddubeau opened this issue 7 years ago • 1 comments

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.)

lddubeau avatar Aug 17 '17 17:08 lddubeau

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.

josteink avatar Aug 17 '17 17:08 josteink