Microsoft/vscode

Markdown preview is not automatically opened when md file is opened via command-line and no VS code instance was already running

Open

#197,374 创建于 2023年11月3日

在 GitHub 查看
 (4 评论) (0 反应) (1 负责人)TypeScript (10,221 fork)batch import
bugcustom-editorshelp wanted

仓库指标

Star
 (74,848 star)
PR 合并指标
 (平均合并 11小时 43分钟) (30 天内合并 1,000 个 PR)

描述

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:

  1. Change the setting change shown above.
  2. Create a simple markup file C:\temp\test.md
  3. Close all open VS code instances
  4. Execute code C:\temp\test.md
  5. 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.

贡献者指南