Open yume-chan opened 2 years ago
Found a simpler repro steps without the setting:
https://user-images.githubusercontent.com/1330321/135034362-08df5ecc-2c43-4736-80a4-9d822e55e3ca.mp4
As if it's still being formatted in JavaScript mode
Here's the tsserver log from this case: tsserver.log
When the language mode changes from JS to TS, we call updateOpen
:
{"seq":18,"type":"request","command":"updateOpen","arguments":{"changedFiles":[],"closedFiles":["^/untitled/Untitled-1"],"openFiles":[]}}
...
{"seq":19,"type":"request","command":"updateOpen","arguments":{"changedFiles":[],"closedFiles":[],"openFiles":[{"file":"^/untitled/Untitled-1","fileContent":"Promise.resolve<number>(42)","projectRootPath":"/Users/matb/projects/san","scriptKindName":"TS"}]}}
I think this call pattern is correct but the language mode doesn't end up being changed
@mjbvz pretty sure formatting is done on the syntax server. Would you possibly need to duplicate the updateOpen call between both the semantic and syntax servers? I could be way off here, not really sure how that coordination is supposed to work.
Possibly similar issue : #42613
@andrewbranch Oh yes good point, here's the syntax server logs:
When the language mode changes, we do try closing and then re-opening the file on the syntax server as well
TS Template added by @mjbvz
TypeScript Version: 4.5.0-dev.20210929
Search Terms
Issue Type: Bug
"files.defaultLanguage": "javascript"
File: New Untitled File
commandChange Language Mode
command and selectTypeScript
Promise.resolve<number>(42)
Format Document
commandExpected result: nothing changes
Actual result: incorrect format result
If save this untitled file somewhere, and run
Format Document
again, it produces the correct result.VS Code version: Code 1.60.2 (7f6ab5485bbc008386c4386d08766667e155244e, 2021-09-22T12:00:31.514Z) OS version: Windows_NT x64 10.0.19043 Restricted Mode: No
System Info
|Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz (4 x 3193)| |GPU Status|2d_canvas: enabledgpu_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.80GB (1.73GB free)| |Process Argv|--disable-extensions --crash-reporter-id 12b48bde-d2e1-4ed1-bea5-c909d40e482f| |Screen Reader|no| |VM|0%|
A/B Experiments
``` vsliv368cf:30146710 vsreu685:30147344 python383cf:30185419 pythonvspyt602:30300191 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstes516:30244333 pythonvspyt639:30300192 pythontb:30283811 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscorecescf:30358481 pythondataviewer:30285071 pythonvsuse255:30340121 vscod805:30301674 pythonvspyt200:30340761 binariesv615:30325510 vsccppwtct:30364498 pythonvssor306:30344512 bridge0708:30335490 pygetstartedt2:30371810 dockerwalkthrucf:30370837 bridge0723:30353136 pythonrunftest32:30373476 pythonf5test824:30373475 javagetstartedt:30364666 pythonvspyt187:30373474 pydsgst2:30361792 ```Also reproducible on latest insiders build: