Skip to content

Fixes #5363 - Honor AllowedTypes on initial OpenDialog mixed-mode load#5403

Merged
tig merged 4 commits into
developfrom
copilot/fix-opendialog-allowedtypes-respect
May 26, 2026
Merged

Fixes #5363 - Honor AllowedTypes on initial OpenDialog mixed-mode load#5403
tig merged 4 commits into
developfrom
copilot/fix-opendialog-allowedtypes-respect

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 25, 2026

Proposed Changes/Todos

  • Ensure the initial mixed-mode file listing honors AllowedTypes even when Path is set before the dialog finishes initialization

    • FileDialog.EndInit () now refreshes any prebuilt state after assigning the initial CurrentFilter
    • This closes the gap where the first render showed all files until a directory change rebuilt state
  • Add a focused regression test for the failing initialization order

    • Covers OpenMode.Mixed
    • Covers AllowedTypes configured before showing the dialog
    • Covers Path assigned before EndInit ()
  • Behavior

    • Before: setting Path early could build State before CurrentFilter existed, so mixed mode showed unfiltered files until navigation refreshed the dialog
    • After: once the initial filter is established, any existing state is rebuilt immediately, so the first view is filtered correctly
using FileDialog fd = new OpenDialog ()
{
    OpenMode = OpenMode.Mixed,
    AllowedTypes = [new AllowedType ("View", ".Designer.cs")]
};

fd.Path = "/some/path";
fd.EndInit (); // now refreshes existing state after CurrentFilter is set

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

Copilot AI changed the title [WIP] Fix OpenDialog not respecting AllowedTypes until directory change Honor AllowedTypes on initial OpenDialog mixed-mode load May 25, 2026
Copilot finished work on behalf of tig May 25, 2026 01:18
Copilot AI requested a review from tig May 25, 2026 01:18
@tig tig marked this pull request as ready for review May 25, 2026 03:29
@tig tig requested a review from Copilot May 25, 2026 03:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates FileDialog initialization so that when AllowedTypes is configured and Path is set before EndInit () completes, the initial mixed-mode listing is immediately rebuilt using the now-established CurrentFilter (avoiding an initially unfiltered first render).

Changes:

  • In FileDialog.EndInit (), refreshes any pre-existing State after setting the initial CurrentFilter from AllowedTypes.
  • Adds a regression test covering mixed-mode initialization where Path is assigned before EndInit (), ensuring AllowedTypes is respected on first load.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Terminal.Gui/Views/FileDialogs/FileDialog.cs Rebuilds existing state during EndInit () after establishing the initial type filter.
Tests/UnitTestsParallelizable/Views/FileDialogResultTests.cs Adds regression test validating initial mixed-mode filtering when Path is set prior to EndInit ().

Comment thread Tests/UnitTestsParallelizable/Views/FileDialogResultTests.cs Outdated
@tig tig changed the title Honor AllowedTypes on initial OpenDialog mixed-mode load Fixes #5363 - Honor AllowedTypes on initial OpenDialog mixed-mode load May 25, 2026
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>
@tig tig requested review from BDisp and tznind May 25, 2026 19:23
@tig
Copy link
Copy Markdown
Member

tig commented May 25, 2026

Need @tznind to approve since he reported it.

…alog-allowedtypes-respect

# Conflicts:
#	Tests/UnitTestsParallelizable/Views/FileDialogResultTests.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenDialog with Mixed mode does not respect AllowedTypes until changing directory

5 participants