@@ -1148,6 +1148,8 @@ void AddNoResultsItem()
1148
1148
1149
1149
public void PopulateOmnibarSuggestionsForCommandPaletteMode ( )
1150
1150
{
1151
+ var newSuggestions = new List < NavigationBarSuggestionItem > ( ) ;
1152
+
1151
1153
if ( ContentPageContext . SelectedItems . Count == 1 && ContentPageContext . SelectedItem is not null && ! ContentPageContext . SelectedItem . IsFolder )
1152
1154
{
1153
1155
try
@@ -1176,7 +1178,7 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
1176
1178
}
1177
1179
}
1178
1180
1179
- OmnibarCommandPaletteModeSuggestionItems . Add ( newItem ) ;
1181
+ newSuggestions . Add ( newItem ) ;
1180
1182
}
1181
1183
}
1182
1184
catch ( Exception ex )
@@ -1198,22 +1200,52 @@ public void PopulateOmnibarSuggestionsForCommandPaletteMode()
1198
1200
PrimaryDisplay = command . Description ,
1199
1201
HotKeys = command . HotKeys ,
1200
1202
SearchText = OmnibarCommandPaletteModeText ,
1201
- } ) ;
1203
+ } )
1204
+ . Where ( item => item . Text != Commands . OpenCommandPalette . Description . ToString ( )
1205
+ && item . Text != Commands . EditPath . Description . ToString ( ) ) ;
1202
1206
1203
- foreach ( var item in suggestionItems )
1204
- {
1205
- if ( item . Text != Commands . OpenCommandPalette . Description . ToString ( ) )
1206
- OmnibarCommandPaletteModeSuggestionItems . Add ( item ) ;
1207
- }
1207
+ newSuggestions . AddRange ( suggestionItems ) ;
1208
1208
1209
- if ( OmnibarCommandPaletteModeSuggestionItems . Count is 0 )
1209
+ if ( newSuggestions . Count == 0 )
1210
1210
{
1211
- OmnibarCommandPaletteModeSuggestionItems . Add ( new NavigationBarSuggestionItem ( )
1211
+ newSuggestions . Add ( new NavigationBarSuggestionItem ( )
1212
1212
{
1213
1213
PrimaryDisplay = string . Format ( Strings . NoCommandsFound . GetLocalizedResource ( ) , OmnibarCommandPaletteModeText ) ,
1214
1214
SearchText = OmnibarCommandPaletteModeText ,
1215
1215
} ) ;
1216
1216
}
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
+ }
1217
1249
}
1218
1250
1219
1251
[ Obsolete ( "Remove once Omnibar goes out of experimental." ) ]
0 commit comments