@@ -1148,6 +1148,8 @@ void AddNoResultsItem()
11481148
11491149 public void PopulateOmnibarSuggestionsForCommandPaletteMode ( )
11501150 {
1151+ var newSuggestions = new List < NavigationBarSuggestionItem > ( ) ;
1152+
11511153 if ( ContentPageContext . SelectedItems . Count == 1 && ContentPageContext . SelectedItem is not null && ! ContentPageContext . SelectedItem . IsFolder )
11521154 {
11531155 try
@@ -1176,7 +1178,7 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
11761178 }
11771179 }
11781180
1179- OmnibarCommandPaletteModeSuggestionItems . Add ( newItem ) ;
1181+ newSuggestions . Add ( newItem ) ;
11801182 }
11811183 }
11821184 catch ( Exception ex )
@@ -1198,22 +1200,52 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
11981200 PrimaryDisplay = command . Description ,
11991201 HotKeys = command . HotKeys ,
12001202 SearchText = OmnibarCommandPaletteModeText ,
1201- } ) ;
1203+ } )
1204+ . Where ( item => item . Text != Commands . OpenCommandPalette . Description . ToString ( )
1205+ && item . Text != Commands . EditPath . Description . ToString ( ) ) ;
12021206
1203- foreach ( var item in suggestionItems )
1204- {
1205- if ( item . Text != Commands . OpenCommandPalette . Description . ToString ( ) )
1206- OmnibarCommandPaletteModeSuggestionItems . Add ( item ) ;
1207- }
1207+ newSuggestions . AddRange ( suggestionItems ) ;
12081208
1209- if ( OmnibarCommandPaletteModeSuggestionItems . Count is 0 )
1209+ if ( newSuggestions . Count == 0 )
12101210 {
1211- OmnibarCommandPaletteModeSuggestionItems . Add ( new NavigationBarSuggestionItem ( )
1211+ newSuggestions . Add ( new NavigationBarSuggestionItem ( )
12121212 {
12131213 PrimaryDisplay = string . Format ( Strings . NoCommandsFound . GetLocalizedResource ( ) , OmnibarCommandPaletteModeText ) ,
12141214 SearchText = OmnibarCommandPaletteModeText ,
12151215 } ) ;
12161216 }
1217+
1218+ if ( ! OmnibarCommandPaletteModeSuggestionItems . IntersectBy ( newSuggestions , x => x . PrimaryDisplay ) . Any ( ) )
1219+ {
1220+ for ( int index = 0 ; index < newSuggestions . Count ; index ++ )
1221+ {
1222+ if ( index < OmnibarCommandPaletteModeSuggestionItems . Count )
1223+ OmnibarCommandPaletteModeSuggestionItems [ index ] = newSuggestions [ index ] ;
1224+ else
1225+ OmnibarCommandPaletteModeSuggestionItems . Add ( newSuggestions [ index ] ) ;
1226+ }
1227+
1228+ while ( OmnibarCommandPaletteModeSuggestionItems . Count > newSuggestions . Count )
1229+ OmnibarCommandPaletteModeSuggestionItems . RemoveAt ( OmnibarCommandPaletteModeSuggestionItems . Count - 1 ) ;
1230+ }
1231+ else
1232+ {
1233+ foreach ( var s in OmnibarCommandPaletteModeSuggestionItems . ExceptBy ( newSuggestions , x => x . PrimaryDisplay ) . ToList ( ) )
1234+ OmnibarCommandPaletteModeSuggestionItems . Remove ( s ) ;
1235+
1236+ for ( int index = 0 ; index < newSuggestions . Count ; index ++ )
1237+ {
1238+ if ( OmnibarCommandPaletteModeSuggestionItems . Count > index
1239+ && OmnibarCommandPaletteModeSuggestionItems [ index ] . PrimaryDisplay == newSuggestions [ index ] . PrimaryDisplay )
1240+ {
1241+ OmnibarCommandPaletteModeSuggestionItems [ index ] = newSuggestions [ index ] ;
1242+ }
1243+ else
1244+ {
1245+ OmnibarCommandPaletteModeSuggestionItems . Insert ( index , newSuggestions [ index ] ) ;
1246+ }
1247+ }
1248+ }
12171249 }
12181250
12191251 [ Obsolete ( "Remove once Omnibar goes out of experimental." ) ]
0 commit comments