Skip to content

Default view for markdown files doesn't work the first time vscode is started #244597

Closed

Description

@Alexander-ARTV

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.98.2
  • OS Version: Win10 22H2

Steps to Reproduce:

  1. In the settings, add Item: *.md, Value: vscode.markdown.preview.editor under Workbench: Editor Associations
  2. Close vscode
  3. With no vscode instances running, open .md file from explorer
  4. Text editor view is opened instead of the preview
  5. Verify that the setting is registered by checking Ctrl + P > View: Reopen editor with..., Markdown Preview is listed as Default
  6. Open another .md file, this second one is now opened in preview mode

Activity

  1. added
    markdown-ext
    bug
    help wanted
    on Dec 9, 2025
  2. added this to the Backlog milestone on Dec 9, 2025
  3. added
    unreleased
    insiders-released
    and removed
    unreleased
    on Apr 9, 2026
  4. bryanchen-d commented on Apr 13, 2026

    @bryanchen-d
    Collaborator

    Still repro on 1.116.0-insider

  5. removed
    insiders-released
    on Apr 13, 2026
  6. Sad-theFaceless commented on Aug 20, 2026

    @Sad-theFaceless

    Still bugged as of today

  7. goldensoda commented on Aug 27, 2026

    @goldensoda

    I can reproduce this with a third-party custom Markdown editor as well.

    Environment

    • VS Code: 1.118.1 (Stable, x64)
    • Windows 10 Home China, 22H2, build 19045.6466
    • Extension: [email protected]
    • Custom editor ID: markdownForHumans.editor

    Configuration

    "workbench.editorAssociations": {
        "*.md": "markdownForHumans.editor",
        "*.markdown": "markdownForHumans.editor"
    }
  8. tzipora-rose commented on Oct 20, 2026

    @tzipora-rose

    We believe two faults make this fail on a cold start, and #308739 fixed neither of them. With both fixed in my install of VSCodium 1.135.06055, whose code is the same here, opening an .md file from File Explorer with no window open now opens it in its associated custom editor. Line numbers are from main at c975dfc.

    1. resolveEditor looks the editor up in a map made before its wait

    Fix 1 is one line after the await, this._flattenedEditors = this._flattenEditorsMap();, which draft PR #312551 adds.

    2. On a cold start, no custom editor is registered with the resolver yet

    Fix 2, which we applied in my install, was changing that registration to InstantiationType.Eager, as it was before #161871. Having the startup contribution actually create the service would do the same. #161871 was a startup-performance change, so you may prefer something narrower.

    We haven't tried fix 2 alone. From the code, it would cover custom editors already in the memento but not one that isn't there yet (the first start after installing its extension, say), since that one is registered only during the wait; so both seem needed.

    What I saw

    VSCodium 1.135.06055 on Windows 10 Pro 22H2, opening an .md file from File Explorer with no window open (double-click, or its path pasted into the address bar; both run VSCodium.exe "%1"):

    changes in workbench.desktop.main.js "*.md" in workbench.editorAssociations opened in
    none vscode.markdown.preview.editor the text editor
    fix 1 vscode.markdown.preview.editor the text editor
    fix 1 md-live.editor (a third-party custom editor) the text editor
    fixes 1 and 2 md-live.editor the custom editor

    The extension-host logs agree: in the three failing starts the Markdown extensions were activated only by onLanguage:markdown; in the working one, MD Live was activated by onCustomEditor:md-live.editor about 3 s after the start, before any onLanguage:markdown activation. The same failure is reported on VS Code 1.142.0 in #325506, and from the command line in #197374.

    Investigated and written in collaboration with Claudia in Claude Code.

  9. tzipora-rose commented on Oct 20, 2026

    @tzipora-rose

    This should now be fixed by #342988, merged on 2026-10-20 for VS Code 1.144.0. It fixes both causes from my comment above: resolveEditor now rebuilds its map of editors after waiting for extensions, and a new startup contribution registers custom editors with the resolver, so a cold start should open the associated editor. Thanks Logan Ramos (@lramos15) for the fix!

    Written in collaboration with Claudia in Claude Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bughelp wantedmarkdown-extverification-found

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions