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

File reformatting to 4 spaces for indentation on save. #28327

Closed
mavidser opened this issue Jun 9, 2017 · 7 comments
Closed

File reformatting to 4 spaces for indentation on save. #28327

mavidser opened this issue Jun 9, 2017 · 7 comments
Assignees
Labels
editor-autoindent Editor auto indentation issues

Comments

@mavidser
Copy link

mavidser commented Jun 9, 2017

EDIT: It's not just indentation. It reformats the file to some defaults it sees fit. a=b;c=d; gets spit into multiple lines on saving. Also, replicated this issue in HTML files.

  • VSCode Version: 1.13.0
  • OS Version: macOS 10.12.4

Steps to Reproduce:

  1. Open a JavaScript project in a workspace. (Was unable to reproduce in a typescript and go project. But verified in 2 different javascript projects).
  2. Open a file using 2 spaces for indentation. Hit Cmd-S for . The file reformats to 4 spaces.

When I open the file, the indent guides are at 2 stops. The status bar says Spaces: 2. But hitting save reformats the code to 4 spaces. Happens with eslint enabled and disabled. No workspace settings. Global setting has files.formatOnSave as off by default and editor.tabSize as 2. This has started happening recently after updating to the latest version.

If I reopen the file now, the status bar says Spaces: 4 with 4 spaces in indent guides. Now I select Indent using Spaces > 2, and Reindent Lines. This restores the 2 spaces formatting. But hitting save again turns the 2 spaces into 4.

@vscodebot vscodebot bot added the new release label Jun 9, 2017
@mavidser mavidser changed the title File reformatting to 4 spaces for indentation File reformatting to 4 spaces for indentation on save. Jun 9, 2017
@rebornix rebornix added the editor-autoindent Editor auto indentation issues label Jun 12, 2017
@mavidser
Copy link
Author

It's not just indentation. It reformats the file to some defaults it sees fit. a=b;c=d; gets spit into multiple lines on saving. Also, replicated this issue in HTML files.

@mohd-akram
Copy link

This suddenly started happening to me as well.

@mavidser
Copy link
Author

Yeah. And now I've seen it happen in so many cases. Unminifies HTML, JS on save, with four spaces. Happens in js, json, html files. but doesn't in ts, c, go for me.

@albelko
Copy link

albelko commented Jul 18, 2017

I have the same. Anybody solved it?

@mohd-akram
Copy link

It turns out I had a different issue which was related to the C# extension.

@albelko
Copy link

albelko commented Jul 18, 2017

I found that JS-CSS-HTML Formatter extension affects on indents.
Thanks, anyway!

@mavidser
Copy link
Author

^This seems to be the problem. Set onSave as false in the extension's formatter config to fix this problem.

Closing this issue for now.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-autoindent Editor auto indentation issues
Projects
None yet
Development

No branches or pull requests

6 participants