@@ -1068,48 +1068,48 @@ public async Task PopulateOmnibarSuggestionsForPathMode()
10681068 newSuggestions . AddRange ( currPath . Select ( x => new OmnibarPathModeSuggestionModel ( x . Path , x . Item . DisplayName ) ) ) ;
10691069 newSuggestions . AddRange ( subPath . Select ( x => new OmnibarPathModeSuggestionModel ( x . Path , PathNormalization . Combine ( currPath . First ( ) . Item . DisplayName , x . Item . DisplayName ) ) ) ) ;
10701070 }
1071+ }
10711072
1072- // If there are no suggestions, show "No suggestions"
1073- if ( newSuggestions . Count is 0 )
1074- {
1075- AddNoResultsItem ( ) ;
1076- }
1073+ // If there are no suggestions, show "No suggestions"
1074+ if ( newSuggestions . Count is 0 )
1075+ {
1076+ AddNoResultsItem ( ) ;
1077+ }
10771078
1078- // Check whether at least one item is in common between the old and the new suggestions
1079- // since Omnibar suggestions popup becoming empty causes flickering
1080- if ( ! PathModeSuggestionItems . IntersectBy ( newSuggestions , x => x . DisplayName ) . Any ( ) )
1079+ // Check whether at least one item is in common between the old and the new suggestions
1080+ // since the suggestions popup becoming empty causes flickering
1081+ if ( ! PathModeSuggestionItems . IntersectBy ( newSuggestions , x => x . DisplayName ) . Any ( ) )
1082+ {
1083+ // No items in common, update the list in-place
1084+ for ( int index = 0 ; index < newSuggestions . Count ; index ++ )
10811085 {
1082- // No items in common, update the list in-place
1083- for ( int index = 0 ; index < newSuggestions . Count ; index ++ )
1086+ if ( index < PathModeSuggestionItems . Count )
10841087 {
1085- if ( index < PathModeSuggestionItems . Count )
1086- {
1087- PathModeSuggestionItems [ index ] = newSuggestions [ index ] ;
1088- }
1089- else
1090- {
1091- PathModeSuggestionItems . Add ( newSuggestions [ index ] ) ;
1092- }
1088+ PathModeSuggestionItems [ index ] = newSuggestions [ index ] ;
1089+ }
1090+ else
1091+ {
1092+ PathModeSuggestionItems . Add ( newSuggestions [ index ] ) ;
10931093 }
1094-
1095- while ( PathModeSuggestionItems . Count > newSuggestions . Count )
1096- PathModeSuggestionItems . RemoveAt ( PathModeSuggestionItems . Count - 1 ) ;
10971094 }
1098- else
1099- {
1100- // At least an element in common, show animation
1101- foreach ( var s in PathModeSuggestionItems . ExceptBy ( newSuggestions , x => x . DisplayName ) . ToList ( ) )
1102- PathModeSuggestionItems . Remove ( s ) ;
11031095
1104- for ( int index = 0 ; index < newSuggestions . Count ; index ++ )
1096+ while ( PathModeSuggestionItems . Count > newSuggestions . Count )
1097+ PathModeSuggestionItems . RemoveAt ( PathModeSuggestionItems . Count - 1 ) ;
1098+ }
1099+ else
1100+ {
1101+ // At least an element in common, show animation
1102+ foreach ( var s in PathModeSuggestionItems . ExceptBy ( newSuggestions , x => x . DisplayName ) . ToList ( ) )
1103+ PathModeSuggestionItems . Remove ( s ) ;
1104+
1105+ for ( int index = 0 ; index < newSuggestions . Count ; index ++ )
1106+ {
1107+ if ( PathModeSuggestionItems . Count > index && PathModeSuggestionItems [ index ] . DisplayName == newSuggestions [ index ] . DisplayName )
11051108 {
1106- if ( PathModeSuggestionItems . Count > index && PathModeSuggestionItems [ index ] . DisplayName == newSuggestions [ index ] . DisplayName )
1107- {
1108- PathModeSuggestionItems [ index ] = newSuggestions [ index ] ;
1109- }
1110- else
1111- PathModeSuggestionItems . Insert ( index , newSuggestions [ index ] ) ;
1109+ PathModeSuggestionItems [ index ] = newSuggestions [ index ] ;
11121110 }
1111+ else
1112+ PathModeSuggestionItems . Insert ( index , newSuggestions [ index ] ) ;
11131113 }
11141114 }
11151115
0 commit comments