Browse Source

Fixed quit scenario bug. WorkerApp, when hidden, was eating QuitKey

Tig 1 year ago
parent
commit
5b03d739a6
2 changed files with 6 additions and 11 deletions
  1. 1 1
      Terminal.Gui/Views/ListView.cs
  2. 5 10
      UICatalog/Scenarios/BackgroundWorkerCollection.cs

+ 1 - 1
Terminal.Gui/Views/ListView.cs

@@ -702,7 +702,7 @@ public class ListView : View
     /// <returns><see langword="true"/> if the <see cref="OpenSelectedItem"/> event was fired.</returns>
     public bool OnOpenSelectedItem ()
     {
-        if (_source.Count <= _selected || _selected < 0 || OpenSelectedItem is null)
+        if (_source is null || _source.Count <= _selected || _selected < 0 || OpenSelectedItem is null)
         {
             return false;
         }

+ 5 - 10
UICatalog/Scenarios/BackgroundWorkerCollection.cs

@@ -295,7 +295,7 @@ public class BackgroundWorkerCollection : Scenario
 
             KeyDown += (s, e) =>
                        {
-                           if (e.KeyCode == KeyCode.Esc)
+                           if (e == Application.QuitKey)
                            {
                                OnReportClosed (this, EventArgs.Empty);
                            }
@@ -357,6 +357,9 @@ public class BackgroundWorkerCollection : Scenario
             };
             Add (_listLog);
 
+            // We don't want WorkerApp to respond to the quitkey
+            KeyBindings.Remove (Application.QuitKey);
+
             Closing += WorkerApp_Closing;
             Closed += WorkerApp_Closed;
         }
@@ -439,15 +442,7 @@ public class BackgroundWorkerCollection : Scenario
                                              {
                                                  // Failed
                                                  WriteLog (
-                                                           $"Exception occurred {
-                                                               e.Error.Message
-                                                           } on Worker {
-                                                               staging.StartStaging
-                                                           }.{
-                                                               staging.StartStaging
-                                                               :fff} at {
-                                                               DateTime.Now
-                                                           }"
+                                                           $"Exception occurred {e.Error.Message} on Worker {staging.StartStaging}.{staging.StartStaging:fff} at {DateTime.Now}"
                                                           );
                                              }
                                              else if (e.Cancelled)