-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
Format document inserting 4 spaces instead of 2 #15316
Comments
@frankorama What is shown on the VSCode status line? |
UTF-8 LF JavaScript. The file I'm working in has a .js extension. Some strange behaviour: It seems to be back to 2 spaces now, but when I select all, shift+tab so all the indentation is removed, then right-click "format code", nothing happens. I thought I had a syntax problem or forgot a semicolon somewhere, but everything looks good. I removed all my comments as well. Same behaviour. |
I am having this same problem with my .js files. The status line shows "Spaces: 2" but when I Format Document, it changes all my tabs to 4 spaces. I'm using v1.7.1 on OSX. |
The problem with the automatic formatting is only happening in VS Code for OSX. I also work on a laptop with Windows 10 and the same .js file formats normally. |
This might be related to the JS-CSS-HTML-formatter extension. Removing that extension seems to have solved the problem for me. |
I only had DUST language support and JSON prettify extensions installed. Removed them and the formatting is working normally now. Not sure which one was causing the problem though. Should have tested bette. |
I am seeing the same issue with Windows 10. It strangely only happens the second time I open a file. For example, if I open up this: then hit The same occurs for I have disabled all the extensions I have installed to see if it was any of them causing this, but it does not appear to be the case as disabling them made no difference. |
@joaomoreno isn't this what you have seen with TS/JS and reported to them? |
It could be microsoft/TypeScript#12175 |
I'm having exactly the same issue as @dylanparry . OSX 10.11.6 VSCode 1.7.1. |
I don't know if this helps, but it really is a random problem. I just installed ESLint, JavaScript (ES6) code snippits, and jshint extensions. The formatting function stopped working. I disabled and reenabled the 3 extensions and formatting started working again. Difficult to pinoint exactly which extension is causing the problem because the problem doesn't occur until after a couple of hours of coding sometimes. |
The issue intermittently happens and very often, but only on files that contains ES6 functions notations |
I am observing this issue as well. Although, I identified no reproducable issue yet, I recognized, that the formatter will internally crash after some time of work. After that it will just use default settings rather than user settings and eventually does not format code at all anymore. Is there any log, where suppressed issues might be logged to? After restart it works again for some time. |
@maybeec if this is a TS / JS issue then it could be showing up in that log. You can see the log in the output window after adding this setting to your user setting:
If you (and others) could post the output of the log when you see the issue here that would be helpful. Also if anyone has a workspace that reproduces this issue please post to help us reproduce. |
I enabled the setting and will have a look when the error occurred. So where can I find the log file? |
If you open the output window the log information is there... I don't know where the log file is actually created... @dbaeumer do you know the location of the TS log file that gets sent to the output window? Maybe the data is not persisted. |
Ok basically, I was able to have a view at the output during observation of the error. So what I was observing now is, that this behavior comes up, when having multiple instances of vscode open for some time. After some time, the formatter begins to behave odd |
To get the server log you can use an environment variable to control the location. Something like |
This seems to be fixed in the latest release, which bundles a new version of TypeScript. Can anyone else confirm this? |
Yes, I think that TS fixed a number of issues around formatting in 2.1.4 and 2.1.5. Please open a new issue if you still see this problem in VSCode 1.9 using TS 2.1.5+ |
Happening on vscode 1.13.1 for me on mac os latest, plugins: debugger for chrome 3.1.4, ESLint 1.2.11, React native Tools 0.3.2. Language: JavaScript, UTF-8 |
Not fixed, I still have this issue on VSCode 1.13.1 and TS 2.3.0. UPDATE: In my case the issue was caused by a third party formatting plugin overriding the defaults. |
Not fixed, still have this issue. |
Works here with
Default without either of these were 4 spaces. |
edit: solved. (See 2 comments below) Still have this issue:
But pressing ALT + SHIFT + F still indented with 2 spaces |
@colorpump Any extensions enabled related to HTML formatter? Please try without extensions. To force tabs, use |
It was my fault. I'm sorry for confusion |
Steps to Reproduce:
The text was updated successfully, but these errors were encountered: