Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion Terminal.Gui/Views/FileDialogs/FileDialog.TableView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private bool TableView_KeyDown (Key keyEvent)
// BUGBUG: See https://github.com/gui-cs/Terminal.Gui/issues/5087#issuecomment-4328093883
private void TableViewOnValueChanged (object? sender, ValueChangedEventArgs<TableSelection?> e)
{
if (!_tableView.HasFocus || _tableView.Value is null || _tableView.Table?.Rows == 0)
if (_pushingState || !_tableView.HasFocus || _tableView.Value is null || _tableView.Table?.Rows == 0)
{
return;
}
Expand Down
46 changes: 46 additions & 0 deletions Tests/IntegrationTests/FluentTests/FileDialogTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,50 @@ public void SaveFileDialog_TableView_UpDown_PreserveFilenameOnDirectoryChanges_T

c.Stop ();
}

[Theory]
[MemberData (nameof (GetAllDriverNames))]
public void SaveFileDialog_TableView_EnterOnDirectory_PreserveFilenameOnDirectoryChanges_True (string d)
{
// Copilot
SaveDialog? sd = null;
MockFileSystem? fs = null;

using AppTestHelper c = With.A (() =>
{
IRunnable r = NewSaveDialog (out sd, out fs);
sd.Style.PreserveFilenameOnDirectoryChanges = true;
sd.AllowedTypes = [new AllowedType ("C# File", ".cs")];

return r;
}, 100, 20, d)
.Then (_ =>
{
sd!.Path = fs!.Path.Combine (GetFileSystemRoot (fs), "hello.cs");
})
.ScreenShot ("Save dialog with filename", _out)
.Focus<TableView> (_ => true)
.KeyDown (Key.CursorDown)
.ScreenShot ("After selecting logs directory", _out)
.KeyDown (Key.Enter)
.ScreenShot ("After entering logs directory", _out)
.Then (_ =>
{
Assert.True (sd!.IsRunning);
Assert.True (sd.Canceled);
Assert.Contains ("logs", sd.Path);
Assert.EndsWith ("hello.cs", sd.Path);
})
.KeyDown (Key.Enter)
.ScreenShot ("After entering parent directory row", _out)
.Then (_ =>
{
Assert.True (sd!.IsRunning);
Assert.True (sd.Canceled);
Assert.DoesNotContain ("logs", sd.Path);
Assert.EndsWith ("hello.cs", sd.Path);
});

c.Stop ();
}
}
Loading