Skip to content

Commit

Permalink
Fixes gui-cs#3885. ableView's CollectionNavigator sometimes doesn't w…
Browse files Browse the repository at this point in the history
…ork right.
  • Loading branch information
BDisp committed Feb 28, 2025
1 parent c00de4a commit 96d0a2a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Terminal.Gui/Text/TableCollectionNavigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class TableCollectionNavigator : CollectionNavigatorBase
/// <inheritdoc/>
protected override object ElementAt (int idx)
{
int col = tableView.SelectedColumn;
int col = tableView.FullRowSelect ? 0 : tableView.SelectedColumn;
object rawValue = tableView.Table [idx, col];

ColumnStyle style = tableView.Style.GetColumnStyleIfAny (col);
Expand Down
23 changes: 23 additions & 0 deletions UnitTests/Views/TableViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3364,6 +3364,29 @@ public void CanTabOutOfTableViewUsingCursor_Left_ClearsSelectionFirst ()
Application.Top.Dispose ();
}

[Theory]
[InlineData (true, 0, 1)]
[InlineData (true, 1, 1)]
[InlineData (false, 0, 1)]
[InlineData (false, 1, 0)]
public void TableCollectionNavigator_FullRowSelect_True_False (bool fullRowSelect, int selectedCol, int expectedRow)
{
TableView tableView = new () { FullRowSelect = fullRowSelect, SelectedColumn = selectedCol};
tableView.BeginInit ();
tableView.EndInit ();

DataTable dt = new ();
dt.Columns.Add ("A");
dt.Columns.Add ("B");

dt.Rows.Add (1, 2);
dt.Rows.Add (3, 4);
tableView.Table = new DataTableSource (dt);
tableView.SelectedColumn = selectedCol;

Assert.Equal (expectedRow, tableView.CollectionNavigator.GetNextMatchingItem (0, "3".ToCharArray () [0]));
}

/// <summary>
/// Creates 3 views on <see cref="Application.Current"/> with the focus in the
/// <see cref="TableView"/>. This is a helper method to setup tests that want to
Expand Down

0 comments on commit 96d0a2a

Please sign in to comment.