Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1959. GoToEnd should not fail on an empty TreeView #1960

Merged
merged 2 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Terminal.Gui/Views/TreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ public void GoToEnd ()
{
var map = BuildLineMap ();
ScrollOffsetVertical = Math.Max (0, map.Count - Bounds.Height + 1);
SelectedObject = map.Last ().Model;
SelectedObject = map.LastOrDefault ()?.Model;

SetNeedsDisplay ();
}
Expand Down
9 changes: 9 additions & 0 deletions UnitTests/TreeViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,15 @@ public void GoTo_OnlyAppliesToExposedObjects ()
Assert.Equal (1, tree.ScrollOffsetVertical);
}

[Fact]
public void GoToEnd_ShouldNotFailOnEmptyTreeView ()
{
var tree = new TreeView ();

var exception = Record.Exception (() => tree.GoToEnd ());

Assert.Null (exception);
}

[Fact]
public void ObjectActivated_CustomKey ()
Expand Down