microsoft / vscode

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

Fallback to default language if `files.associations` points to a invalid language #194759

Open mcm-ham opened 1 year ago

mcm-ham commented 1 year ago

Type: Bug

Open .yaml file in VSCode and it's recognized as plain text. I can manually change file association but if I reopen that file or open another file it goes back to plain text.

Looks similar to: https://github.com/microsoft/vscode/issues/127159

I've tried reloading with extensions disabled (still happens), and searched for @builtin yaml and can confirm it's enabled.

VS Code version: Code 1.82.3 (fdb98833154679dbaa7af67a5a29fe19e55c2b73, 2023-10-02T11:09:17.749Z) OS version: Darwin arm64 23.0.0 Modes:

System Info |Item|Value| |---|---| |CPUs|Apple M1 (8 x 24)| |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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|3, 9, 5| |Memory (System)|8.00GB (0.08GB free)| |Process Argv|--crash-reporter-id bfcf6f59-63c2-4c83-bfc4-61465df520ff| |Screen Reader|no| |VM|0%|
Extensions: none
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscoreces:30445986 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 pythonvs932:30410667 py29gd2263:30792226 vsclangdc:30486549 c4g48928:30535728 dsvsc012cf:30540253 pynewext54:30695312 azure-dev_surveyone:30548225 2e4cg342:30602488 89544117:30613380 showlangstatbar:30737416 962ge761:30841074 a2ce3375:30757347 7ij38806:30736111 pythonfmttext:30731395 fixshowwlkth:30771522 showindicator:30805244 pythongtdpath:30769146 i26e3531:30792625 pythonnosmt12:30797651 pythonidxpt:30805730 pythonnoceb:30805159 copilotsettingc:30839828 dsvsc013:30795093 dsvsc014:30804076 diffeditorv2:30821572 pythonmhint1:30842940 dsvsc015:30845448 ```
mcm-ham commented 1 year ago

Note it works correctly if file extension is .yml. If I choose Configure File Association for .yaml it indicates it's already associated, and proceeding to choose that extension correctly adds association in user settings but still doesn't work.

Screenshot 2023-10-04 at 12 00 06 PM

aeschli commented 1 year ago

I just verified that this works for me by creating a foo.yaml. It gets associated to the YAML language mode. Anything special about the full path of the file? Did you check all your settings files that there's no association configured?

@bpasero Any idea?

vscodenpa commented 1 year ago

Please diagnose the root cause of the issue by running the command F1 > Help: Troubleshoot Issue and following the instructions. Once you have done that, please update the issue with the results.

Happy Coding!

TylerLeonhardt commented 1 year ago

I was assigned because I own language guessing, but my stuff only comes in for Untitled files & extension-less files. Since this issue calls out the file is .yaml, this isn't an issue with my automatic language detection

mcm-ham commented 1 year ago

My fault, workspace settings was hidden so didn't think to check and only checked user settings. Indeed there is file association for:

"files.associations": {
  "**/pipelines/*.yaml": "azure-pipelines"
}

And I don't have that extension installed. Would it make sense to fallback to VSCode default file association if language doesn't exist (due to missing extension) instead of plain text?

bpasero commented 1 year ago

Would it make sense to fallback to VSCode default file association if language doesn't exist (due to missing extension) instead of plain text?

Maybe, but that might also be something that we do not know upfront if extensions are involved.

//cc @alexdima