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 geöffnet am 3. Nov. 2023

Auf GitHub ansehen
 (4 Kommentare) (0 Reaktionen) (1 zugewiesene Person)TypeScript (10.221 Forks)batch import
bugcustom-editorshelp wanted

Repository-Metriken

Stars
 (74.848 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 11h 43m) (1.000 gemergte PRs in 30 T)

Beschreibung

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.

Contributor Guide