Ensure MultiSelected is never null and always contains Path if relevant

This commit is contained in:
tznind
2023-03-23 23:12:02 +00:00
parent 05d12ccd51
commit da63caa563

View File

@@ -555,6 +555,7 @@ namespace Terminal.Gui {
/// </summary>
/// <remarks>If selecting only a single file/directory then you should use <see cref="Path"/> instead.</remarks>
public IReadOnlyList<string> MultiSelected { get; private set; }
= Enumerable.Empty<string> ().ToList ().AsReadOnly ();
/// <inheritdoc/>
@@ -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<string> ().ToList ().AsReadOnly ():
new List<string> () { Path }.AsReadOnly ();
}
this.Canceled = false;
Application.RequestStop ();
}