Skip to content

Commit 93a0859

Browse files
committed
ListView cleanup 3
1 parent 3e48ce2 commit 93a0859

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Terminal.Gui/Views/ListView.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,14 @@ public ListView ()
168168
}
169169

170170
/// <inheritdoc />
171-
protected override void OnFrameChanged (in Rectangle frame)
171+
protected override void OnViewportChanged (DrawEventArgs e)
172172
{
173173
SetContentSize (new Size (MaxLength, _source?.Count ?? Viewport.Height));
174+
}
175+
176+
/// <inheritdoc />
177+
protected override void OnFrameChanged (in Rectangle frame)
178+
{
174179
EnsureSelectedItemVisible ();
175180
}
176181

@@ -394,6 +399,10 @@ public bool UnmarkAllButSelected ()
394399
/// <summary>Ensures the selected item is always visible on the screen.</summary>
395400
public void EnsureSelectedItemVisible ()
396401
{
402+
if (_selected == -1)
403+
{
404+
return;
405+
}
397406
if (_selected < Viewport.Y)
398407
{
399408
Viewport = Viewport with { Y = _selected };

0 commit comments

Comments
 (0)