Skip to content

How should we handle indentation inside strings? #47

Open
@lddubeau

Description

@lddubeau

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions