Markdown preview is not automatically opened when md file is opened via command-line and no VS code instance was already running
#197,374 opened on Nov 3, 2023
Repository metrics
- Stars
- (74,848 stars)
- PR merge metrics
- (Avg merge 11h 43m) (1,000 merged PRs in 30d)
Description
Does this issue occur when all extensions are disabled?: Yes
I read various topics on how to achieve that Markdown files are automatically displayed as preview (e.g. #2766, https://stackoverflow.com/a/63541437/150978).
The only partial working solution was adding in setting.json
"workbench.editorAssociations": {
"*.md": "vscode.markdown.preview.editor"
}
However this only works if VS code is already running. If no VS code instance is running and you execute code C:\<somepath>\test.md then the md file is opened in edit view and not preview mode.
Version: 1.84.0 (user setup)
Commit: d037ac076cee195194f93ce6fe2bdfe2969cc82d
Date: 2023-11-01T11:29:04.398Z
Electron: 25.9.2
ElectronBuildId: 24603566
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.19045
Steps to Reproduce:
- Change the setting change shown above.
- Create a simple markup file
C:\temp\test.md - Close all open VS code instances
- Execute
code C:\temp\test.md - VS code opens and show the editor of the md file
If you repeat the steps but in step 3 do not close all VS code instances, but have one instance running in step 5 correctly the preview will be displayed.
Why does it make a difference if a VS code instance is already running or not? It should not make a diference, so the current behavior is not deterministic which in my opinion means it is a bug.