Skip to content

VS Code's indentation settings aren't overridden #1859

Open
@thorn0

Description

@thorn0

Summary

This was discussed in #1515 (comment) and turned out to be a separate issue.

Steps To Reproduce:

  1. create an empty directory
  2. create .prettierrc in it, with this content: {"tabWidth": 2}
  3. create an empty index.js

Expected result

When I open the empty file,

  • I should see "Spaces: 2" in the status bar
  • Tab should insert 2 spaces

Actual result

When I opened this directory in VS Code and opened index.js, I saw "Spaces: 4" in the status bar. Pressing the Tab key inserted 4 spaces. After adding some code with indentation to this file, formatting it with Prettier (it got correctly indented with 2 spaces), closing, and opening the file again, VS Code's autodetection worked (as editor.detectIndentation is true by default) and this time correctly showed "Spaces: 2" in the status bar, the Tab key started to work as expected too.

Additional information

For my tests, I disabled other extensions that could affect this. In particular, EditorConfig and ESLint.

The EditorConfig extension doesn't have this problem. It changes the behavior of VS Code even in empty files.

#1327 might be related (the extension seems to fail to override VS Code's behavior in that case too).

VS Code Version:

1.54.3

Prettier Extension Version:

6.3.1

OS and version:

Windows 10 x64 20H2

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp-wantedNot something we plan on doing, but we will take a pull request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions