File tree Expand file tree Collapse file tree 2 files changed +55
-5
lines changed
EditorFeatures/Core.Wpf/Suggestions
VisualStudio/IntegrationTest/IntegrationTests/CSharp Expand file tree Collapse file tree 2 files changed +55
-5
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 44
55#nullable disable
66
7- using System ;
8- using System . Collections . Generic ;
97using System . Collections . Immutable ;
108using System . Linq ;
119using System . Threading ;
1917using Microsoft . VisualStudio . IntegrationTest . Utilities . Input ;
2018using Roslyn . Test . Utilities ;
2119using Xunit ;
22- using Xunit . Abstractions ;
2320using ProjectUtils = Microsoft . VisualStudio . IntegrationTest . Utilities . Common . ProjectUtils ;
2421
2522namespace Roslyn . VisualStudio . IntegrationTests . CSharp
@@ -574,6 +571,38 @@ static void Main(string[] args)
574571 VisualStudio . Editor . Verify . TextContains ( "implicit" ) ;
575572 }
576573
574+ [ WorkItem ( 57157 , "https://github.com/dotnet/roslyn/issues/57157" ) ]
575+ [ WpfFact , Trait ( Traits . Feature , Traits . Features . CodeActionsAddImport ) ]
576+ public void AddFuzzyUsingAfterGenerateVariable ( )
577+ {
578+ SetUpEditor ( @"
579+ namespace X
580+ {
581+ class Formatter
582+ {
583+ }
584+ }
585+ class Program
586+ {
587+ void Main()
588+ {
589+ $$formatter = new GooFormatter();
590+ }
591+ }
592+ class GooFormatter
593+ {
594+ }" ) ;
595+
596+ VisualStudio . Editor . InvokeCodeActionList ( ) ;
597+ var expectedItems = new [ ]
598+ {
599+ "Generate variable 'formatter'" ,
600+ "Formatter - using X;" ,
601+ } ;
602+
603+ VisualStudio . Editor . Verify . CodeActions ( expectedItems , ensureExpectedItemsAreOrdered : true ) ;
604+ }
605+
577606 [ WpfFact , Trait ( Traits . Feature , Traits . Features . CodeActionsAddImport ) ]
578607 public void OrderFixesByCursorProximityLeft ( )
579608 {
You can’t perform that action at this time.
0 commit comments