Răsfoiți Sursa

Update the ContentSize on the CollectionChanged event.

BDisp 1 an în urmă
părinte
comite
479d1d3558
2 a modificat fișierele cu 4 adăugiri și 3 ștergeri
  1. 2 1
      Terminal.Gui/Views/ListView.cs
  2. 2 2
      UnitTests/Views/ListViewTests.cs

+ 2 - 1
Terminal.Gui/Views/ListView.cs

@@ -291,6 +291,8 @@ public class ListView : View
 
     private void Source_CollectionChanged (object sender, NotifyCollectionChangedEventArgs e)
     {
+        SetContentSize (new Size (_source?.Length ?? Viewport.Width, _source?.Count ?? Viewport.Width));
+
         if (Source is { Count: > 0 } && _selected > Source.Count - 1)
         {
             SelectedItem = Source.Count - 1;
@@ -528,7 +530,6 @@ public class ListView : View
                 int offset = _selected < Viewport.Height - 1
                                  ? Math.Max (Viewport.Height - _selected + 1, 0)
                                  : Math.Max (_selected - Viewport.Height - +1, 0);
-                SetContentSize (Viewport.Size with { Height = Viewport.Height + offset });
                 Viewport = Viewport with { Y = offset };
             }
 

+ 2 - 2
UnitTests/Views/ListViewTests.cs

@@ -255,8 +255,6 @@ public class ListViewTests
         TestHelpers.AssertDriverContentsWithFrameAre (
                                                       @"
 ┌──────────┐
-│Line17    │
-│Line18    │
 │Line19    │
 │          │
 │          │
@@ -265,6 +263,8 @@ public class ListViewTests
 │          │
 │          │
 │          │
+│          │
+│          │
 └──────────┘",
                                                       _output
                                                      );