Context
DocumentEditorHost.OpenAsync threw 'No document loader registered for .docx' because PluginActivationService.ActivateIfNeeded is fire-and-forget (Task.Run). The DocumentLoadersPlugin hadn't finished registering when the loader lookup ran. Fixed across two commits.
Root cause (commit 6bb6405c)
Poll ExtensionRegistry every 200ms for up to 3s before failing, giving the lazy plugin time to register its IDocumentLoader extensions.
Second failure (commit 02eaac1d)
The polling loop always timed out because FileOpenedEvent had not yet been published when OpenAsync started — MainWindow publishes it after tab creation, which is after OpenAsync is already running.
Fix: when no IDocumentLoader matches, publish FileOpenedEvent directly from DocumentEditorHost (via _ideContext.IDEEvents) before polling. This triggers PluginActivationService.OnFileOpened synchronously, enqueuing the plugin load. The 3s poll then sees the loader appear within ~200–400ms.
Files affected
Controls/DocumentEditorHost.xaml.cs
Follow-up
Context
DocumentEditorHost.OpenAsyncthrew'No document loader registered for .docx'becausePluginActivationService.ActivateIfNeededis fire-and-forget (Task.Run). TheDocumentLoadersPluginhadn't finished registering when the loader lookup ran. Fixed across two commits.Root cause (commit
6bb6405c)Poll
ExtensionRegistryevery 200ms for up to 3s before failing, giving the lazy plugin time to register itsIDocumentLoaderextensions.Second failure (commit
02eaac1d)The polling loop always timed out because
FileOpenedEventhad not yet been published whenOpenAsyncstarted —MainWindowpublishes it after tab creation, which is afterOpenAsyncis already running.Fix: when no
IDocumentLoadermatches, publishFileOpenedEventdirectly fromDocumentEditorHost(via_ideContext.IDEEvents) before polling. This triggersPluginActivationService.OnFileOpenedsynchronously, enqueuing the plugin load. The 3s poll then sees the loader appear within ~200–400ms.Files affected
Controls/DocumentEditorHost.xaml.csFollow-up
IDocumentLoaderRegisteredevent fromExtensionRegistryFileOpenedEventpublish ifMainWindowlater also publishes it