Skip to content

Commit a7f48d9

Browse files
Merge pull request #57171 from CyrusNajmabadi/addUsingPriority17.0-b
Ensure low-pri fixes go in the right async lightbulb bucket.
2 parents 5500014 + afc6991 commit a7f48d9

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

src/EditorFeatures/Core.Wpf/Suggestions/AsyncSuggestedActionsSource.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ private async Task GetSuggestedActionsWorkerAsync(
9797
// items should be pushed higher up, and less important items shouldn't take up that much space.
9898
var currentActionCount = 0;
9999

100+
using var _ = ArrayBuilder<SuggestedActionSet>.GetInstance(out var lowPrioritySets);
101+
100102
// Collectors are in priority order. So just walk them from highest to lowest.
101103
foreach (var collector in collectors)
102104
{
@@ -122,8 +124,27 @@ private async Task GetSuggestedActionsWorkerAsync(
122124

123125
await foreach (var set in allSets)
124126
{
125-
currentActionCount += set.Actions.Count();
126-
collector.Add(set);
127+
if (priority == CodeActionRequestPriority.High && set.Priority == SuggestedActionSetPriority.Low)
128+
{
129+
// if we're processing the high pri bucket, but we get action sets for lower pri
130+
// groups, then keep track of them and add them in later when we get to that group.
131+
lowPrioritySets.Add(set);
132+
}
133+
else
134+
{
135+
currentActionCount += set.Actions.Count();
136+
collector.Add(set);
137+
}
138+
}
139+
140+
if (priority == CodeActionRequestPriority.Normal)
141+
{
142+
// now, add any low pri items we've been waiting on to the final group.
143+
foreach (var set in lowPrioritySets)
144+
{
145+
currentActionCount += set.Actions.Count();
146+
collector.Add(set);
147+
}
127148
}
128149
}
129150

src/VisualStudio/IntegrationTest/IntegrationTests/CSharp/CSharpCodeActions.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
#nullable disable
66

7-
using System;
8-
using System.Collections.Generic;
97
using System.Collections.Immutable;
108
using System.Linq;
119
using System.Threading;
@@ -19,7 +17,6 @@
1917
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
2018
using Roslyn.Test.Utilities;
2119
using Xunit;
22-
using Xunit.Abstractions;
2320
using ProjectUtils = Microsoft.VisualStudio.IntegrationTest.Utilities.Common.ProjectUtils;
2421

2522
namespace Roslyn.VisualStudio.IntegrationTests.CSharp
@@ -486,7 +483,7 @@ public class P2 { }");
486483
}
487484

488485
[WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateType)]
489-
public void GFUFuzzyMatchAfterRenameTracking()
486+
public void GFUFuzzyMatchAfterRenameTrackingAndAfterGenerateType()
490487
{
491488
SetUpEditor(@"
492489
namespace N
@@ -511,12 +508,12 @@ static void Main(string[] args)
511508
var expectedItems = new[]
512509
{
513510
"Rename 'P2' to 'Foober'",
514-
"Goober - using N;",
515511
"Generate type 'Foober'",
516512
"Generate class 'Foober' in new file",
517513
"Generate class 'Foober'",
518514
"Generate nested class 'Foober'",
519515
"Generate new type...",
516+
"Goober - using N;",
520517
"Suppress or Configure issues",
521518
"Suppress CS0168",
522519
"in Source",

0 commit comments

Comments
 (0)