From d232715e62b60aa5d0fef809c396bf5ea4526fa4 Mon Sep 17 00:00:00 2001 From: BDisp Date: Sun, 2 Aug 2020 11:17:10 +0100 Subject: [PATCH] Fixes #844. Now selects the correct Directory. --- Example/demo.cs | 2 +- Terminal.Gui/Windows/FileDialog.cs | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Example/demo.cs b/Example/demo.cs index 60a27c413..68307007a 100644 --- a/Example/demo.cs +++ b/Example/demo.cs @@ -305,7 +305,7 @@ static class Demo { Application.Run (d); if (!d.Canceled) - MessageBox.Query (50, 7, "Selected File", string.Join (", ", d.FilePaths), "Ok"); + MessageBox.Query (50, 7, "Selected File", d.FilePaths.Count > 0 ? string.Join (", ", d.FilePaths) : d.FilePath, "Ok"); } public static void ShowHex (Toplevel top) diff --git a/Terminal.Gui/Windows/FileDialog.cs b/Terminal.Gui/Windows/FileDialog.cs index 3d41e16b3..ec2a03526 100644 --- a/Terminal.Gui/Windows/FileDialog.cs +++ b/Terminal.Gui/Windows/FileDialog.cs @@ -347,13 +347,15 @@ namespace Terminal.Gui { } } - internal bool ExecuteSelection () + internal bool ExecuteSelection (bool isPrompt = false) { var isDir = infos [selected].Item2; if (isDir) { - Directory = Path.GetFullPath (Path.Combine (Path.GetFullPath (Directory.ToString ()), infos [selected].Item1)); - DirectoryChanged?.Invoke (Directory); + if (!isPrompt) { + Directory = Path.GetFullPath (Path.Combine (Path.GetFullPath (Directory.ToString ()), infos [selected].Item1)); + DirectoryChanged?.Invoke (Directory); + } } else { FileChanged?.Invoke (infos [selected].Item1); if (canChooseFiles) { @@ -467,8 +469,8 @@ namespace Terminal.Gui { }; Add (dirLabel, dirEntry); - this.nameFieldLabel = new Label ("Open: ") { - X = 6, + this.nameFieldLabel = new Label ("File(s): ") { + X = 3, Y = 3 + msgLines, }; nameEntry = new TextField ("") { @@ -500,7 +502,7 @@ namespace Terminal.Gui { IsDefault = true, }; this.prompt.Clicked += () => { - dirListView.ExecuteSelection (); + dirListView.ExecuteSelection (true); canceled = false; Application.RequestStop (); };