Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
7 changes: 5 additions & 2 deletions Terminal.Gui/Views/FileDialogs/FileDialog.TableView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,11 @@ private Scheme ColorGetter (CellColorGetterArgs args)
{
Normal = new Attribute (foreground, background),
HotNormal = new Attribute (foreground, background),
Focus = new Attribute (background, foreground),
HotFocus = new Attribute (background, foreground)
Focus = args.RowScheme.Focus,
HotFocus = args.RowScheme.HotFocus,
Active = args.RowScheme.Active,
HotActive = args.RowScheme.HotActive,
Disabled = args.RowScheme.Disabled
};
}

Expand Down
49 changes: 49 additions & 0 deletions Tests/UnitTestsParallelizable/Views/FileDialogColorTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copilot

using System.IO.Abstractions.TestingHelpers;
using System.Reflection;

namespace UnitTests.Views;

public class FileDialogColorTests
{
[Fact]
public void ParentRowColorGetter_UsesSelectionScheme_WhenNavigatingUp ()
{
MockFileSystem fileSystem = new ();
fileSystem.AddDirectory ("/test-dir/sub-dir");

using SaveDialog dialog = new TestableSaveDialog (fileSystem);
dialog.PushState (fileSystem.DirectoryInfo.New ("/test-dir/sub-dir"), false);

FieldInfo? tableViewField = typeof (FileDialog).GetField ("_tableView", BindingFlags.Instance | BindingFlags.NonPublic);
Assert.NotNull (tableViewField);

TableView tableView = Assert.IsType<TableView> (tableViewField!.GetValue (dialog));
Assert.NotNull (tableView.Table);
Assert.True (dialog.State!.Children [0].IsParent);

ColumnStyle nameStyle = tableView.Style.GetOrCreateColumnStyle (0);
Assert.NotNull (nameStyle.ColorGetter);

object cellValue = tableView.Table [0, 0];
string representation = cellValue.ToString () ?? string.Empty;
Scheme rowScheme = tableView.GetScheme ();
Scheme effectiveScheme = nameStyle.ColorGetter! (
new CellColorGetterArgs (
tableView.Table,
0,
0,
cellValue,
representation,
rowScheme))!;
Comment thread
tig marked this conversation as resolved.
Outdated

Assert.Equal (rowScheme.Focus, effectiveScheme.Focus);
Assert.Equal (rowScheme.Active, effectiveScheme.Active);
}

private sealed class TestableSaveDialog : SaveDialog
{
public TestableSaveDialog (MockFileSystem fileSystem) : base (fileSystem) { }
}
}
Loading