microsoft / vscode

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

formatter doesnt work #128869

Closed ivamaria closed 3 years ago

ivamaria commented 3 years ago

Issue Type: Bug

formatter doesnt work

VS Code version: Code 1.58.1 (2aeda6b18e13c4f4f9edf6667158a6b8d408874b, 2021-07-13T06:58:28.115Z) OS version: Windows_NT x64 10.0.19043 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz (8 x 1498)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.79GB (7.57GB free)| |Process Argv|C:\\Users\\Irakli\\Desktop\\skillbox --crash-reporter-id b0aad357-f527-4906-a270-abd369251a13| |Screen Reader|yes| |VM|0%|
Extensions (17) Extension|Author (truncated)|Version ---|---|--- githistory|don|0.6.17 gitlens|eam|11.6.0 vscode-html-css|ecm|1.10.2 EditorConfig|Edi|0.16.4 prettier-for-handlebars-vscode|emb|3.0.0 git-project-manager|fel|1.7.1 beautify|Hoo|1.5.0 start-bash|hua|0.0.1 kite|kit|0.147.0 vscode-JS-CSS-HTML-formatter|lon|0.2.3 start-git-bash|McC|1.2.1 HTMLHint|mka|0.10.0 vscode-css-navigation|puc|1.10.7 http-server|qua|0.0.1 LiveServer|rit|5.6.1 bash-debug|rog|0.3.9 move-repositories|tgr|0.0.2
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383:30185418 pythonvspyt602:30300191 vspor879:30202332 vspor708:30202333 vspor363:30204092 pythonvspyt639:30300192 pythontb:30283811 pythonvspyt551cf:30311713 vspre833:30321513 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 pythondataviewer:30285071 vscus158:30321503 pythonvsuse255:30335481 vscod805cf:30301675 pythonvspyt200cf:30331938 vscextlang:30333561 binariesv615:30325510 vsccppwtct:30329789 bridge0708:30335490 ```
Sparragus commented 3 years ago

My formatting is also behaving very wonky.

It's only working on some files. These files can be of the same filetype with the same language selected. So, for example, I may have two different .tsx files, both with TypeScript React as the language, and only one would be formatted on save. To be clear, the issue is only happening with format on save. If I open the commands panel and select "Format Document", it will indeed format the document.

Furthermore, when it does format, it formats but the files stays "Unsaved". What I mean by that is where the tab with the filename and the close button will not show the close button but rather the circle/dot indicating that the file isn't saved. If I hit Cmd-S again, it will indeed save it.

Here are my details:

VS Code version: Code - Insiders 1.59.0-insider (50b3811fdc5b5c80ca516a2edfffedcbd464b033, 2021-07-15T05:12:24.272Z) OS version: Darwin x64 20.5.0 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (16 x 2300)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|3, 2, 2| |Memory (System)|32.00GB (0.28GB free)| |Process Argv|. --crash-reporter-id 10f5353f-d199-44d8-aa40-3f8ec2a47b10| |Screen Reader|no| |VM|0%|
Extensions (70) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|2.1.0 vscode-icalendar|af4|1.0.1 vscode-erb-beautify|ali|0.2.0 vscode-open-file-folder|auc|0.0.4 azure-blockchain|AzB|1.6.0 vscode-tailwindcss|bra|0.6.13 solargraph|cas|0.23.0 npm-intellisense|chr|1.3.1 path-intellisense|chr|2.3.0 jsrefactor|cms|2.20.6 gitignore|cod|0.7.0 bracket-pair-colorizer|Coe|1.0.61 vscode-svgviewer|css|2.0.0 hex-to-rgba|dak|1.0.0 vscode-eslint|dba|2.1.23 vscode-faker|dee|1.5.0 gitlens|eam|11.6.0 EditorConfig|Edi|0.16.4 vsc-material-theme|Equ|33.2.0 vsc-material-theme-icons|equ|1.2.2 prettier-vscode|esb|8.0.1 vs-code-xml-format|fab|0.1.5 file-icons|fil|1.0.29 auto-rename-tag|for|0.1.7 copilot|Git|1.2.1991 gc-excelviewer|Gra|3.0.42 headwind|hey|1.7.0 rails-snippets|Hri|1.0.8 plantuml|jeb|2.15.1 vscode-styled-components|jpo|1.6.4 solidity|Jua|0.0.124 language-haskell|jus|3.4.0 endwise|kai|1.4.2 haml|kar|1.3.1 rainbow-csv|mec|1.9.1 vscode-docker|ms-|1.14.0 remote-containers|ms-|0.188.1 remote-ssh|ms-|0.65.7 remote-ssh-edit|ms-|0.65.7 remote-wsl|ms-|0.58.2 vscode-remote-extensionpack|ms-|0.21.0 azure-account|ms-|0.9.8 vsliveshare|ms-|1.0.4580 color-highlight|nau|2.4.0 language-liquid|nei|0.1.1 vetur|oct|0.34.1 vscode-gitignore-generator|pio|1.0.3 vscode-react-refactor|pla|1.1.3 polacode|pnp|0.3.4 prisma|Pri|2.27.0 ruby|reb|0.28.1 vscode-commons|red|0.0.6 vscode-yaml|red|0.21.1 yo|sam|0.9.3 code-settings-sync|Sha|3.4.3 mdx|sil|0.1.0 vscode-react-code-actions|spa|0.0.3 hex-to-tailwind|Ted|1.1.0 graphviz-interactive-preview|tin|0.0.11 solidity-visual-auditor|tin|0.1.0 vscode-ethover|tin|0.0.6 vscode-inline-bookmarks|tin|0.0.23 vscode-solidity-flattener|tin|0.0.10 vscode-input-sequence|tom|0.2.0 vscode-todo-highlight|way|1.0.4 vscode-ruby|win|0.28.0 vscode-import-cost|wix|2.15.0 change-case|wma|1.0.0 better-align|wwm|1.1.6 markdown-all-in-one|yzh|3.4.0 (2 theme extensions excluded)
A/B Experiments ``` vsliv695:30137379 vsins829:30139715 vsliv368:30146709 vsreu685:30147344 python383:30185418 pythonvspyt602:30291494 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstes627:30244334 pythonvspyt639:30291487 pythontb:30258533 pythonvspyt551cf:30291413 vspre833:30321513 pythonptprofiler:30281269 vshan820:30294714 pythondataviewer:30285072 vscus158:30321503 pythonvsuse255:30319630 vscod805:30301674 pythonvspyt200:30323110 vscextlang:30310088 vsccppwt:30312692 bridge0708:30335490 ```
nathonius commented 3 years ago

I consistently see the behavior @Sparragus described where the formatting is successful but the file remains unsaved.

Version: 1.59.0-insider (user setup) Commit: 50b3811fdc5b5c80ca516a2edfffedcbd464b033 Date: 2021-07-15T05:13:58.348Z Electron: 13.1.6 Chrome: 91.0.4472.124 Node.js: 14.16.0 V8: 9.1.269.36-electron.0 OS: Windows_NT x64 10.0.22000

yamachu commented 3 years ago

I was able to reproduce it at my own hands, so I also tried the old version. As others have pointed out, it seems to reproduce from version https://github.com/microsoft/vscode/commit/50b3811fdc5b5c80ca516a2edfffedcbd464b033 .

It did not reproduce in version https://github.com/microsoft/vscode/commit/9520f0a515e7e24802c92f885a0efb242fca3831 .

Version: 1.59.0-insider Commit: 50b3811fdc5b5c80ca516a2edfffedcbd464b033 Date: 2021-07-15T05:12:24.272Z Electron: 13.1.6 Chrome: 91.0.4472.124 Node.js: 14.16.0 V8: 9.1.269.36-electron.0 OS: Darwin x64 20.5.0

I used Prettier for the formatter.

jrieken commented 3 years ago

@yamachu @OfficerHalf @Sparragus please use most recent insiders

@ivamaria please add repo steps

OldStarchy commented 3 years ago

@jrieken 50b3811fdc5b5c80ca516a2edfffedcbd464b033 is the latest version (available via the "Check for Updates") as of typing this message (unix timestamp 1626680758)

Version: 1.59.0-insider (user setup) Commit: 50b3811fdc5b5c80ca516a2edfffedcbd464b033 Date: 2021-07-15T05:13:58.348Z Electron: 13.1.6 Chrome: 91.0.4472.124 Node.js: 14.16.0 V8: 9.1.269.36-electron.0 OS: Windows_NT x64 10.0.19041
gif ![Animation (4)](https://user-images.githubusercontent.com/15243523/126122398-d2b5bf3f-a5fb-4271-a285-db00cff972b4.gif) (gif slightly edited to remove some fumbles)

Steps to reproduce

  1. Open new window
  2. Create new file
  3. Set language (any language, tested: javascript & typescript ("Prettier", "TypeScript and JavaScript Language Features"), php ("PHP CS Fixer"))
  4. Write some code
  5. Save -> file saves, then formats. file is still dirty
  6. Save again -> file saves

Does this happen with extensions disabled: Yes

yamachu commented 3 years ago

@jrieken 599f5d2c67571f84a045a59eb3423bc254ee87d9 could not download via VSCode's Check for Updates... .

I have a copy of the latest download link, so I downloaded it, but I can't run it.

https://az764295.vo.msecnd.net/insider/599f5d2c67571f84a045a59eb3423bc254ee87d9/VSCode-darwin.zip

jrieken commented 3 years ago

Latest version is 599f5d2c67571f84a045a59eb3423bc254ee87d9

yamachu commented 3 years ago

We could not download it.

https://user-images.githubusercontent.com/1955233/126126099-1a58a644-66f1-4c5d-b676-62e32cc6e46c.mov

yamachu commented 3 years ago

In 599f5d2c67571f84a045a59eb3423bc254ee87d9, this issue doesn't reproduce.

$ open Visual\ Studio\ Code\ -\ Insiders.app
The application cannot be opened, error=Error Domain=NSPOSIXErrorDomain Code=16 "Resource busy"

$  open Visual\ Studio\ Code\ -\ Insiders.app/Contents/MacOS/Electron

Version: 1.59.0-insider Commit: 599f5d2c67571f84a045a59eb3423bc254ee87d9 Date: 2021-07-16T09:55:33.041Z Electron: 13.1.6 Chrome: 91.0.4472.124 Node.js: 14.16.0 V8: 9.1.269.36-electron.0 OS: Darwin x64 20.5.0

By the way, why couldn't we download from VS Code? And why we could not launch VSCode.app directly...?

yamachu commented 3 years ago

This issue doesn't reproduce in d624242076d166bb8ce8b314e8d44b8af6100a3d .

Version: 1.59.0-insider Commit: d624242076d166bb8ce8b314e8d44b8af6100a3d Date: 2021-07-19T05:14:11.338Z Electron: 13.1.6 Chrome: 91.0.4472.124 Node.js: 14.16.0 V8: 9.1.269.36-electron.0 OS: Darwin x64 20.5.0

nathonius commented 3 years ago

@jrieken at the time that was the most recent build, but with the latest the issue seems to be fixed.

Version: 1.59.0-insider (user setup) Commit: d624242076d166bb8ce8b314e8d44b8af6100a3d Date: 2021-07-19T05:13:36.046Z Electron: 13.1.6 Chrome: 91.0.4472.124 Node.js: 14.16.0 V8: 9.1.269.36-electron.0 OS: Windows_NT x64 10.0.19041

Sparragus commented 3 years ago

Seems to be fixed. Thank you

jrieken commented 3 years ago

ping @ivamaria