From da63caa5631ce80be3ca2f164191fe97d5d7d0c9 Mon Sep 17 00:00:00 2001 From: tznind Date: Thu, 23 Mar 2023 23:12:02 +0000 Subject: [PATCH] Ensure MultiSelected is never null and always contains Path if relevant --- Terminal.Gui/Windows/FileDialog.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Terminal.Gui/Windows/FileDialog.cs b/Terminal.Gui/Windows/FileDialog.cs index ef0151d5b..19a3e7699 100644 --- a/Terminal.Gui/Windows/FileDialog.cs +++ b/Terminal.Gui/Windows/FileDialog.cs @@ -555,6 +555,7 @@ namespace Terminal.Gui { /// /// If selecting only a single file/directory then you should use instead. public IReadOnlyList MultiSelected { get; private set; } + = Enumerable.Empty ().ToList ().AsReadOnly (); /// @@ -803,6 +804,15 @@ namespace Terminal.Gui { return; } + // if user uses Path selection mode (e.g. Enter in text box) + // then also copy to MultiSelected + if(AllowsMultipleSelection && (!MultiSelected.Any())) { + + MultiSelected = string.IsNullOrWhiteSpace (Path) ? + Enumerable.Empty ().ToList ().AsReadOnly (): + new List () { Path }.AsReadOnly (); + } + this.Canceled = false; Application.RequestStop (); }