From f599246079bc567ba27cd017fac20c6e73e00365 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 25 May 2026 01:11:47 +0000 Subject: [PATCH 1/3] Initial plan From b5c51a2c2a9a3b63ab275712b6fa858527904dce Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 25 May 2026 01:17:05 +0000 Subject: [PATCH 2/3] Fix initial OpenDialog allowed type filtering Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/38f439b3-b6ec-4949-bdad-e74a47ddada3 Co-authored-by: tig <585482+tig@users.noreply.github.com> --- Terminal.Gui/Views/FileDialogs/FileDialog.cs | 5 ++++ .../Views/FileDialogResultTests.cs | 30 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/Terminal.Gui/Views/FileDialogs/FileDialog.cs b/Terminal.Gui/Views/FileDialogs/FileDialog.cs index 5850dcae31..bf7c2d84d1 100644 --- a/Terminal.Gui/Views/FileDialogs/FileDialog.cs +++ b/Terminal.Gui/Views/FileDialogs/FileDialog.cs @@ -315,6 +315,11 @@ public override void EndInit () _typeFilterDropDown?.Visible = true; _typeFilterDropDown?.Source = new ListWrapper (new ObservableCollection (AllowedTypes.Select (a => a.ToString ()!).ToList ())); _typeFilterDropDown?.Value = AllowedTypes [0].ToString () ?? string.Empty; + + if (State is { }) + { + RefreshState (); + } } // if no path has been provided diff --git a/Tests/UnitTestsParallelizable/Views/FileDialogResultTests.cs b/Tests/UnitTestsParallelizable/Views/FileDialogResultTests.cs index b8188e3dbe..5b8f83da0c 100644 --- a/Tests/UnitTestsParallelizable/Views/FileDialogResultTests.cs +++ b/Tests/UnitTestsParallelizable/Views/FileDialogResultTests.cs @@ -221,6 +221,36 @@ public void FileDialog_PathField_BadChars_AreSuppressed (char badChar) Assert.Equal (insertionPointBefore, tbPath.InsertionPoint); } + [Fact] + public void FileDialog_MixedMode_PathSetBeforeEndInit_RespectsAllowedTypes () + { + // Copilot + MockFileSystem fs = new (); + fs.AddDirectory ("/testdir"); + fs.AddDirectory ("/testdir/subdir"); + fs.AddFile ("/testdir/allowed.Designer.cs", new MockFileData ("allowed")); + fs.AddFile ("/testdir/blocked.txt", new MockFileData ("blocked")); + using FileDialog fd = new TestableFileDialog (fs) + { + OpenMode = OpenMode.Mixed, + AllowedTypes = [new AllowedType ("View", ".Designer.cs")] + }; + + fd.Path = "/testdir"; + fd.EndInit (); + + Assert.NotNull (fd.CurrentFilter); + Assert.NotNull (fd.State); + + List visibleEntries = fd.State!.Children + .Where (c => !c.IsParent) + .Select (c => c.FileSystemInfo!.Name) + .OrderBy (name => name) + .ToList (); + + Assert.Equal (["allowed.Designer.cs", "subdir"], visibleEntries); + } + /// Testable subclass that exposes the internal file-system constructor. private sealed class TestableFileDialog : FileDialog { From 812a1b6f4fa2415f3a3e96b4b2e2c691cfaa15c7 Mon Sep 17 00:00:00 2001 From: Tig Date: Sun, 24 May 2026 21:45:43 -0600 Subject: [PATCH 3/3] Use c.Name instead of c.FileSystemInfo!.Name in test Address review comment: FileSystemInfoStats already exposes a safe Name property, so avoid the null-forgiving operator on FileSystemInfo which can legitimately be null for virtual entries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Tests/UnitTestsParallelizable/Views/FileDialogResultTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/UnitTestsParallelizable/Views/FileDialogResultTests.cs b/Tests/UnitTestsParallelizable/Views/FileDialogResultTests.cs index 5b8f83da0c..91fb8ccc74 100644 --- a/Tests/UnitTestsParallelizable/Views/FileDialogResultTests.cs +++ b/Tests/UnitTestsParallelizable/Views/FileDialogResultTests.cs @@ -244,7 +244,7 @@ public void FileDialog_MixedMode_PathSetBeforeEndInit_RespectsAllowedTypes () List visibleEntries = fd.State!.Children .Where (c => !c.IsParent) - .Select (c => c.FileSystemInfo!.Name) + .Select (c => c.Name) .OrderBy (name => name) .ToList ();