diff --git a/src/ObservableCollections/SynchronizedViewList.cs b/src/ObservableCollections/SynchronizedViewList.cs index 8b146a1..73f5f41 100644 --- a/src/ObservableCollections/SynchronizedViewList.cs +++ b/src/ObservableCollections/SynchronizedViewList.cs @@ -190,8 +190,8 @@ private void Parent_ViewChanged(in SynchronizedViewChangedEventArgs e) var oldIndex = listView.RemoveAt(e.OldStartingIndex); var newIndex = listView.Insert(e.NewStartingIndex, e.NewItem.View); OnCollectionChanged(e.WithNewAndOldStartingIndex(newStartingIndex: newIndex, oldStartingIndex: oldIndex)); + return; } - break; case NotifyCollectionChangedAction.Reset: // Clear or drastic changes listView.Clear(IterateFilteredIndexedViewsOfParent()); // clear and fill refresh break; diff --git a/tests/ObservableCollections.Tests/ToNotifyCollectionChangedTest.cs b/tests/ObservableCollections.Tests/ToNotifyCollectionChangedTest.cs index e8f4fa0..ed3e7a3 100644 --- a/tests/ObservableCollections.Tests/ToNotifyCollectionChangedTest.cs +++ b/tests/ObservableCollections.Tests/ToNotifyCollectionChangedTest.cs @@ -1,3 +1,5 @@ +using System.Collections.Specialized; +using System.Diagnostics; using ObservableCollections; namespace ObservableCollections.Tests; @@ -56,4 +58,25 @@ public void ToNotifyCollectionChanged_Filter() e.Current.Should().Be("$4"); e.MoveNext().Should().BeFalse(); } -} \ No newline at end of file + + [Fact] + public void ToNotifyCollectionChanged_Move() + { + var list = new ObservableList { 0, 1, 2, 3 }; + + var view = list.CreateView(i => i) + .ToNotifyCollectionChanged(); + + int moveEventCount = 0; + + view.CollectionChanged += (_, e) => + { + if (e.Action == NotifyCollectionChangedAction.Move) + moveEventCount++; + }; + + list.Move(0, 1); + + moveEventCount.Should().Be(1); + } +}