Skip to content

Formatter is broken when using tabs #12175

Closed
@joaomoreno

Description

@joaomoreno

TypeScript Version: 2.0.8

In VS Code I have configured tabs to be 2 characters wide ("editor.tabSize": 2). I noticed that some lines of code are incorrectly ignored by the formatter when using this setting.

For example, the formatter should outdent line two in the following snippet to 1 tab only, which initially has 2 tabs, and it fails to do so:

const foo = [
		1
];

Any other indentation on that line makes the formatter behave properly and format it with a single tab. It's only when using 2 tabs that it stays put.

It feels like the tab size is incorrectly taken into account when indenting using tabs, when it should simply be ignored. This is confirmed by setting tabSize to 3 and indenting line two with 3 tabs: the formatter will ignore that line. It also reproduces with tabSize of 4 (default) and indenting line two with 4 tabs. And so on...

cc @jrieken

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issueVS Code TrackedThere is a VS Code equivalent to this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions