Wox/ViewModel/ResultsViewModel.cs
/// <summary>
/// Update the results collection with new results, try to keep identical results
/// </summary>
/// <param name="newItems"></param>
Update the results collection with new results, try to keep identical results
Update the results collection with new results try to keep identical results
public void Update(List<ResultViewModel> newItems)
            {
                int newCount = newItems.Count;
                int oldCount = Items.Count;
                int location = newCount > oldCount ? oldCount : newCount;
                for (int i = 0; i < location; i++)
                {
                    ResultViewModel oldResult = this[i];
                    ResultViewModel newResult = newItems[i];
                    if (!oldResult.Equals(newResult))
                    { 
                        this[i] = newResult;
                    }
                    else if (oldResult.Result.Score != newResult.Result.Score)
                    {
                        this[i].Result.Score = newResult.Result.Score;
                    }
                }
                if (newCount >= oldCount)
                {
                    for (int i = oldCount; i < newCount; i++)
                    {
                        Add(newItems[i]);
                    }
                }
                else
                {
                    for (int i = oldCount - 1; i >= newCount; i--)
                    {
                        RemoveAt(i);
                    }
                }
            }
public void Update ( List < ResultViewModel > newItems ) { int newCount = newItems . Count ; int oldCount = Items . Count ; int location = newCount > oldCount ? oldCount : newCount ; for ( int i = 0 ; i < location ; i ++ ) { ResultViewModel oldResult = this [ i ] ; ResultViewModel newResult = newItems [ i ] ; if ( ! oldResult . Equals ( newResult ) ) { this [ i ] = newResult ; } else if ( oldResult . Result . Score != newResult . Result . Score ) { this [ i ] . Result . Score = newResult . Result . Score ; } } if ( newCount >= oldCount ) { for ( int i = oldCount ; i < newCount ; i ++ ) { Add ( newItems [ i ] ) ; } } else { for ( int i = oldCount - 1 ; i >= newCount ; i -- ) { RemoveAt ( i ) ; } } }
Update the results collection with new results, try to keep identical results
Update the results collection with new results try to keep identical results
// result is not the same update it in the current index
newItems
List<ResultViewModel>
None