Tig 8 months ago
parent
commit
5e9535c964

+ 2 - 6
Terminal.Gui/Configuration/ConfigurationManager.cs

@@ -250,12 +250,6 @@ public static class ConfigurationManager
             Reset ();
         }
 
-        // Deafult is always loaded by Reset, so only load it if reset is false
-        if (!reset && Locations.HasFlag (ConfigLocations.Default))
-        {
-            Settings?.UpdateFromResource (typeof (ConfigurationManager).Assembly, $"Terminal.Gui.Resources.{_configFilename}");
-        }
-
         if (Locations.HasFlag (ConfigLocations.GlobalCurrent))
         {
             Settings?.Update ($"./.tui/{_configFilename}");
@@ -295,6 +289,8 @@ public static class ConfigurationManager
         {
             Settings?.Update (Memory, "ConfigurationManager.Memory");
         }
+
+        ThemeManager.SelectedTheme = Settings!["Theme"].PropertyValue as string ?? "Default";
     }
 
     /// <summary>

+ 4 - 2
Terminal.Gui/Configuration/ThemeManager.cs

@@ -110,7 +110,9 @@ public class ThemeManager : IDictionary<string, ThemeScope>
             string oldTheme = _theme;
             _theme = value;
 
-            if ((oldTheme != _theme || oldTheme != Settings! ["Theme"].PropertyValue as string) && Settings! ["Themes"]?.PropertyValue is Dictionary<string, ThemeScope> themes && themes.ContainsKey (_theme))
+            if ((oldTheme != _theme
+                 || oldTheme != Settings! ["Theme"].PropertyValue as string)
+                 && Settings! ["Themes"]?.PropertyValue is Dictionary<string, ThemeScope> themes && themes.ContainsKey (_theme))
             {
                 Settings! ["Theme"].PropertyValue = _theme;
                 Instance.OnThemeChanged (oldTheme);
@@ -148,7 +150,7 @@ public class ThemeManager : IDictionary<string, ThemeScope>
     internal static void Reset ()
     {
         Debug.WriteLine ("Themes.Reset()");
-        Colors.Reset ();    
+        Colors.Reset ();
         Themes?.Clear ();
         SelectedTheme = string.Empty;
     }

+ 1 - 14
UnitTests/Configuration/ConfigurationMangerTests.cs

@@ -161,7 +161,7 @@ public class ConfigurationManagerTests
         dict.Add (new (DeepCopyTest.key), "Esc");
         Assert.Contains (Key.Esc, dict);
 
-        DeepMemberWiseCopy (Key.Q.WithCtrl, DeepCopyTest.key);
+        DeepCopyTest.key = (Key)DeepMemberWiseCopy (Key.Q.WithCtrl, DeepCopyTest.key);
 
         Assert.Equal (Key.Q.WithCtrl, DeepCopyTest.key);
         Assert.Equal (Key.Esc, dict.Keys.ToArray () [0]);
@@ -178,19 +178,6 @@ public class ConfigurationManagerTests
         Assert.True (dict.ContainsKey (Key.Q.WithCtrl));
     }
 
-    //[Fact]
-    //public void Illustrate_DeepMemberWiseCopy_ ()
-    //{
-    //    Assert.Equal (Key.Esc, Application.QuitKey);
-
-    //    var o = UpdateValueFrom (Application.QuitKey);
-    //    DeepMemberWiseCopy (Key.Q.WithCtrl, Application.QuitKey);
-
-    //    Assert.Equal (Key.Q.WithCtrl, Application.QuitKey);
-
-    //    Application.ResetState (true);
-    //}
-
     [Fact]
     public void Load_Raises_Updated ()
     {