Don't compute the information for the code definition window if not open#57307
Conversation
a2c4ff0 to
8408670
Compare
...udio/Core/Def/Implementation/CodeDefinitionWindow/VisualStudioCodeDefinitionWindowService.cs
Show resolved
Hide resolved
...udio/Core/Def/Implementation/CodeDefinitionWindow/VisualStudioCodeDefinitionWindowService.cs
Outdated
Show resolved
Hide resolved
|
@jasonmalinowski are we ready to enable auto-merge on this? |
If the symbol your caret is over is from metadata, producing the output might be really expensive, so let's not do it in that case. The window clears anything when it's opened, so the user won't know it was never doing anything when closed.
f7625d0 to
e3f5ffc
Compare
|
@RikkiGibson Now set. |
| var vsCodeDefView = await GetVsCodeDefViewAsync().ConfigureAwait(true); | ||
|
|
||
| // Switch to the UI thread before using the IVsCodeDefView service | ||
| await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); |
There was a problem hiding this comment.
💡 This method will be more efficient if this call is moved to the start of the method (removes two thread context switches that would occur if the caller is on a background thread and the window is not already initialized, and no penalty for the other cases).
| var vsCodeDefView = await GetVsCodeDefViewAsync().ConfigureAwait(true); | ||
|
|
||
| // Switch to the UI thread before using the IVsCodeDefView service | ||
| await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); |
There was a problem hiding this comment.
📝 This should also be moved up to before the call to GetServiceAsync (same reason)
| // so the user won't notice we weren't doing anything when it was open. | ||
| if (!await _codeDefinitionWindowService.IsWindowOpenAsync(cancellationToken).ConfigureAwait(false)) | ||
| { | ||
| return; |
There was a problem hiding this comment.
❔ How much penalty is there for calling SetContextAsync with an empty set of locations for this case?
There was a problem hiding this comment.
What would be the goal of doing that? Its entirely possible the service will throw away the call, I'm not certain.
If the symbol your caret is over is from metadata, producing the output might be really expensive, so let's not do it in that case. The window clears anything when it's opened, so the user won't know it was never doing anything when closed.