You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Default view for markdown files doesn't work the first time vscode is started #244597
bugIssue identified by VS Code Team member as probable bughelp wantedIssues identified as good community contribution opportunitiesmarkdown-extThe Markdown extension: language features and previewverification-foundIssue verification failed
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
It stores the flattened map of registered editors in _flattenedEditors (line 131).
registerEditor only sets _shouldReFlattenEditors (line 276); the map is rebuilt only when _flattenEditorsMap() is called again (lines 485–490).
Nothing calls it after the wait. getEditor (line 173) goes through getDefaultEditorSelection (line 718) to findMatchingEditors, which iterates the stored map (line 633). An editor registered during the wait isn't found (lines 722–727), and the file falls back to the default text editor (line 179).
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
Custom editors are registered with the resolver by CustomEditorService. Its constructor creates ContributedCustomEditors and registers each of its editors (customEditors.ts lines 76–78 and 166–176). ContributedCustomEditors loads the editors stored from the last session (the customEditors memento) and sets the handler of the customEditors extension point (contributedCustomEditors.ts lines 41–50), which takes only one handler (extensionsRegistry.ts lines 128–133). Until the service exists, nothing handles that extension point, so waiting for extensions registers no custom editor.
The service is registered InstantiationType.Delayed (customEditor.contribution.ts line 19): a constructor that depends on it gets a proxy, which creates the service at the next idle time or at first use; subscribing to its onDid*/onWill* events doesn't create it (instantiationService.ts lines 308–374).
A window started with files to open doesn't restore its editors (layout.ts lines 872–890); it opens the files with openEditors, which resolves them (line 1055). Unless something else used the service first, or an idle period came, CustomEditorService doesn't exist yet at that point, so neither the wait nor fix 1 finds the custom editor.
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.
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.
bugIssue identified by VS Code Team member as probable bughelp wantedIssues identified as good community contribution opportunitiesmarkdown-extThe Markdown extension: language features and previewverification-foundIssue verification failed
Activity
fix: resolve default view for markdown files on first startup (micros…
bryanchen-d commentedon Apr 13, 2026
Still repro on 1.116.0-insider
workbench.editorAssociationsto change the default open mode of markdown to preview doesn't work #192954 as a duplicate of this issueSad-theFaceless commentedon Aug 20, 2026
Still bugged as of today
goldensoda commentedon Aug 27, 2026
I can reproduce this with a third-party custom Markdown editor as well.
Environment
[email protected]markdownForHumans.editorConfiguration
tzipora-rose commentedon Oct 20, 2026
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
.mdfile from File Explorer with no window open now opens it in its associated custom editor. Line numbers are frommainat c975dfc.1.
resolveEditorlooks the editor up in a map made before its wait_flattenedEditors(line 131).registerEditoronly sets_shouldReFlattenEditors(line 276); the map is rebuilt only when_flattenEditorsMap()is called again (lines 485–490).getEditor(line 173) goes throughgetDefaultEditorSelection(line 718) tofindMatchingEditors, which iterates the stored map (line 633). An editor registered during the wait isn't found (lines 722–727), and the file falls back to the default text editor (line 179).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
CustomEditorService. Its constructor createsContributedCustomEditorsand registers each of its editors (customEditors.ts lines 76–78 and 166–176).ContributedCustomEditorsloads the editors stored from the last session (thecustomEditorsmemento) and sets the handler of thecustomEditorsextension point (contributedCustomEditors.ts lines 41–50), which takes only one handler (extensionsRegistry.ts lines 128–133). Until the service exists, nothing handles that extension point, so waiting for extensions registers no custom editor.InstantiationType.Delayed(customEditor.contribution.ts line 19): a constructor that depends on it gets a proxy, which creates the service at the next idle time or at first use; subscribing to itsonDid*/onWill*events doesn't create it (instantiationService.ts lines 308–374).ComplexCustomWorkingCopyEditorHandler, aWorkbenchPhase.BlockStartupcontribution (customEditor.contribution.ts line 42), depends on it with the comment// DO NOT REMOVE (needed on startup to register overrides properly)(customEditorInputFactory.ts line 242), but never uses it, so it only gets the proxy. The comment dates from adopt working copy editor handler and remove custom editor input factory #123308 (May 2021); Delay custom editor service #161871 (September 2022, for Make eager service registration explicit and revisit existing one #159178) changed the registration fromregisterSingleton(ICustomEditorService, CustomEditorService, false)toInstantiationType.Delayed.openEditors, which resolves them (line 1055). Unless something else used the service first, or an idle period came,CustomEditorServicedoesn't exist yet at that point, so neither the wait nor fix 1 finds the custom editor.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
.mdfile from File Explorer with no window open (double-click, or its path pasted into the address bar; both runVSCodium.exe "%1"):workbench.desktop.main.js"*.md"inworkbench.editorAssociationsvscode.markdown.preview.editorvscode.markdown.preview.editormd-live.editor(a third-party custom editor)md-live.editorThe 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 byonCustomEditor:md-live.editorabout 3 s after the start, before anyonLanguage:markdownactivation. 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.
tzipora-rose commentedon Oct 20, 2026
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:
resolveEditornow 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.