Skip to content

Commit

Permalink
Add support for running lightbulbs even when not fully loaded. (#75869)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi authored Nov 12, 2024
2 parents 9980db3 + e0f7781 commit 9b88f4f
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ private void OnTextViewClosed(object sender, EventArgs e)
public async Task<ISuggestedActionCategorySet?> GetSuggestedActionCategoriesAsync(
ISuggestedActionCategorySet requestedActionCategories, SnapshotSpan range, CancellationToken cancellationToken)
{
// Make sure we're explicitly on the background, to do as much as possible in a non-blocking fashion.
await TaskScheduler.Default;
cancellationToken.ThrowIfCancellationRequested();

// This function gets called immediately after operations like scrolling. We want to wait just a small
// amount to ensure that we don't immediately start consuming CPU/memory which then impedes the very
// action the user is trying to perform. To accomplish this, we wait 100ms. That's longer than normal
Expand All @@ -177,12 +181,6 @@ private void OnTextViewClosed(object sender, EventArgs e)
if (workspace == null)
return null;

// never show light bulb if solution is not fully loaded yet
if (!await workspace.Services.GetRequiredService<IWorkspaceStatusService>().IsFullyLoadedAsync(cancellationToken).ConfigureAwait(false))
return null;

cancellationToken.ThrowIfCancellationRequested();

using var asyncToken = state.Target.Owner.OperationListener.BeginAsyncOperation(nameof(GetSuggestedActionCategoriesAsync));
var document = range.Snapshot.GetOpenTextDocumentInCurrentContextWithChanges();
if (document == null)
Expand Down

0 comments on commit 9b88f4f

Please sign in to comment.