Skip to content

Commit

Permalink
Add support for running lightbulbs even when not fully loaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Nov 12, 2024
1 parent d3176f5 commit e0f7781
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 e0f7781

Please sign in to comment.