Skip to content

fix: resolve default view for markdown files on first startup - #308739

Merged
Matt Bierner (mjbvz) merged 1 commit into
microsoft:mainfrom
maruthang:fix/issue-244597-markdown-default-view-startup
Apr 9, 2026
Merged

Matt Bierner (mjbvz) merged 1 commit into
microsoft:mainfrom
maruthang:fix/issue-244597-markdown-default-view-startup

Conversation

@maruthang

Copy link
Copy Markdown
Contributor

Fixes #244597

Summary

Bug: Default view for markdown files doesn't work on first startup -- the user-configured custom editor (e.g., markdown preview) is not used when opening .md files for the first time.

Root Cause: The EditorResolverService uses a cache of glob patterns (persisted via StorageService) to decide whether to wait for extensions to register before resolving editors. On first startup, this cache is empty because it is only populated during onWillSaveState, so the resolver skips waiting for extensions and falls back to the default text editor.

Fix: Added a resourceMatchesUserAssociation() method that checks if the resource matches any user-configured editorAssociations pointing to a non-default editor. This is used as a fallback alongside the existing cache check, ensuring the resolver waits for extensions even on first startup when the cache is empty.

Changes

  • src/vs/workbench/services/editor/browser/editorResolverService.ts: Added resourceMatchesUserAssociation() method and updated the cache check condition to also consider user-configured editor associations as a fallback.
  • src/vs/workbench/services/editor/test/browser/editorResolverService.test.ts: Added regression test that verifies user-configured editor associations resolve correctly even with an empty cache (simulating first startup).

Test Plan

  • Added regression test User-configured editor association resolves on first startup with empty cache #244597
  • Verify on a fresh VS Code profile that opening a .md file uses the configured custom editor (e.g., markdown preview) on first startup
  • Verify existing editor resolution behavior is unchanged for subsequent startups (cache populated)
  • Verify files without user associations still resolve to the default editor

…oft#244597)

Check user-configured editor associations as a fallback when the
editor resolver cache is empty, ensuring custom editors are available
on first startup.
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Benjamin Pasero (@bpasero)

Matched files:

  • src/vs/workbench/services/editor/browser/editorResolverService.ts
  • src/vs/workbench/services/editor/test/browser/editorResolverService.test.ts

@mjbvz Matt Bierner (mjbvz) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@mjbvz
Matt Bierner (mjbvz) merged commit ce7d5e4 into microsoft:main Apr 9, 2026
22 of 23 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.116.0 milestone Apr 9, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jul 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants