microsoft / vscode

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

Unable to format the file before saving it to the disk and vscode provided an wrong error message #231005

Open jht3QAQ opened 2 weeks ago

jht3QAQ commented 2 weeks ago

Type: Bug

1.Create a file by File -> New Text File 2.write code: int main(){return 0;} 3.VSCode recognizes that this is a CPP file 4.use ctrl+shift+f to format this file 5.vscode report "There is no formatter for 'cpp' files installed" 6.use ctrl+s to save it to disk 7.now ctrl+shift+f can format this cpp file

I think saving to the disk is not important for formatting files, so I think this is a bug

VS Code version: Code 1.94.1 (e10f2369d0d9614a452462f2e01cdc4aa9486296, 2024-10-05T05:44:32.189Z) OS version: Windows_NT x64 10.0.19045 Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-10900 CPU @ 2.80GHz (20 x 2808)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off| |Load (avg)|undefined| |Memory (System)|31.72GB (18.35GB free)| |Process Argv|--crash-reporter-id 13ef40b0-cb99-40ac-9172-a42ed7b51063 --crash-reporter-id 13ef40b0-cb99-40ac-9172-a42ed7b51063| |Screen Reader|no| |VM|67%|
Extensions (5) Extension|Author (truncated)|Version ---|---|--- vscode-language-pack-zh-hans|MS-|1.94.2024100909 cmake-tools|ms-|1.19.52 cpptools|ms-|1.21.6 cpptools-extension-pack|ms-|1.3.0 cmake|twx|0.0.17 (1 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30959799 pythongtdpath:30769146 pythonnoceb:30805159 asynctok:30898717 pythonmypyd1:30879173 h48ei257:31000450 pythontbext0:30879054 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 724cj586:31013169 a69g1124:31058053 dvdeprecation:31068756 dwnewjupytercf:31046870 impr_priority:31102340 nativerepl1:31139838 refactort:31108082 pythonrstrctxt:31112756 wkspc-onlycs-t:31132770 wkspc-ranged-t:31151552 cf971741:31144450 defaultse:31146405 5fd0e150:31155592 ```
psnet commented 2 weeks ago

Confirm this with JS and TS files too. For not saved files formatter doesnt work, only after saving them it works

psnet commented 2 weeks ago

@alexdima @mjbvz