Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ private async Task GetSuggestedActionsWorkerAsync(
// items should be pushed higher up, and less important items shouldn't take up that much space.
var currentActionCount = 0;

using var _ = ArrayBuilder<SuggestedActionSet>.GetInstance(out var lowPrioritySets);

// Collectors are in priority order. So just walk them from highest to lowest.
foreach (var collector in collectors)
{
Expand All @@ -122,8 +124,27 @@ private async Task GetSuggestedActionsWorkerAsync(

await foreach (var set in allSets)
{
currentActionCount += set.Actions.Count();
collector.Add(set);
if (priority == CodeActionRequestPriority.High && set.Priority == SuggestedActionSetPriority.Low)
{
// if we're processing the high pri bucket, but we get action sets for lower pri
// groups, then keep track of them and add them in later when we get to that group.
lowPrioritySets.Add(set);
}
else
{
currentActionCount += set.Actions.Count();
collector.Add(set);
}
}

if (priority == CodeActionRequestPriority.Normal)
{
// now, add any low pri items we've been waiting on to the final group.
foreach (var set in lowPrioritySets)
{
currentActionCount += set.Actions.Count();
collector.Add(set);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mavasani this will need to be updated when you add support for an actual 'low pri' bucket. actually, afaict, we should hav the following buckets:

  1. high. this is for Exact-AddUsing, and Rename.
  2. normal. almost everything else.
  3. low. Fuzzy-AddUsing, or any specific fixer that we put into the low group.
  4. lowest. suppress/configure

the general rule is that any fixer in one group can provide fixes for it's group and any group that follows.

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#nullable disable

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
Expand All @@ -19,7 +17,6 @@
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using Roslyn.Test.Utilities;
using Xunit;
using Xunit.Abstractions;
using ProjectUtils = Microsoft.VisualStudio.IntegrationTest.Utilities.Common.ProjectUtils;

namespace Roslyn.VisualStudio.IntegrationTests.CSharp
Expand Down Expand Up @@ -486,7 +483,7 @@ public class P2 { }");
}

[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateType)]
public void GFUFuzzyMatchAfterRenameTracking()
public void GFUFuzzyMatchAfterRenameTrackingAndAfterGenerateType()
{
SetUpEditor(@"
namespace N
Expand All @@ -511,12 +508,12 @@ static void Main(string[] args)
var expectedItems = new[]
{
"Rename 'P2' to 'Foober'",
"Goober - using N;",
"Generate type 'Foober'",
"Generate class 'Foober' in new file",
"Generate class 'Foober'",
"Generate nested class 'Foober'",
"Generate new type...",
"Goober - using N;",
"Suppress or Configure issues",
"Suppress CS0168",
"in Source",
Expand Down