microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.45k stars 28.62k forks source link

javacript code formatting not working after typescript v2.x update #12705

Closed mlakmal closed 7 years ago

mlakmal commented 7 years ago

Steps to Reproduce:

  1. update to latest VS Code insider v1.6.0 and update typescript to v2.0.x
  2. format the javascript code with below workspace settings. "editor.tabSize": 2, "javascript.format.insertSpaceAfterKeywordsInControlFlowStatements": true, "javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true, "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false, "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
  3. above formatting settings are not adhered after typescript v2.0x update

tabsize is 4 and not using above override and spaces are not getting added after function keyword and parenthesis/brackets.

dbaeumer commented 7 years ago

@mlakmal there is a real issue here that the formatter also told otherwise replaces tabs with spaces.

Regarding the tabSize: the file is always formatted using the tab size detected by the editor and shown in the status line. So if the status line says Tab Size: 4 in the lower right corner then we use tabSize: 4 during formatting even with the setting "editor.tabSize": 2.

I will follow up in the TS bug https://github.com/Microsoft/TypeScript/issues/11199 since the fix for this has to come from the TS team.

Keeping the issue open to make sure we have a fix for this for September.

dbaeumer commented 7 years ago

Got fixed for the next update:

cast

mlakmal commented 7 years ago

Thanks @dbaeumer.

dbaeumer commented 7 years ago

Closing.

IgorNovozhilov commented 7 years ago

Repeats for html, the spaces are replaced with tabs, regardless of the settings.

dbaeumer commented 7 years ago

@IgorNovozhilov can you please open a separate issue describing the problem you have with HTML. This was about TS and replacing tabs with spaces :-)