Skip to content

Commit 97e1577

Browse files
Merge pull request #334 from jamesc-skyward/GetDocumentViewAsyncFix
Fix WindowFrame.GetDocumentViewAsync() COMException due to documents pending initialization
2 parents c13028e + e4fdfad commit 97e1577

File tree

1 file changed

+4
-0
lines changed
  • src/toolkit/Community.VisualStudio.Toolkit.Shared/Windows

1 file changed

+4
-0
lines changed

src/toolkit/Community.VisualStudio.Toolkit.Shared/Windows/WindowFrame.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ public async Task<bool> IsOnScreenAsync()
231231
/// <returns><see langword="null"/> if the window isn't a document window.</returns>
232232
public async Task<DocumentView?> GetDocumentViewAsync()
233233
{
234+
// Force the loading of a document that may be pending initialization.
235+
// See https://docs.microsoft.com/en-us/visualstudio/extensibility/internals/delayed-document-loading
236+
_frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out _);
237+
234238
IVsTextView? nativeView = VsShellUtilities.GetTextView(_frame);
235239

236240
if (nativeView != null)

0 commit comments

Comments
 (0)