diff --git a/Terminal.Gui/Configuration/ConfigurationManager.cs b/Terminal.Gui/Configuration/ConfigurationManager.cs index 73c770c751..ff1d021b83 100644 --- a/Terminal.Gui/Configuration/ConfigurationManager.cs +++ b/Terminal.Gui/Configuration/ConfigurationManager.cs @@ -199,9 +199,14 @@ internal static void Initialize () foreach (KeyValuePair hardCodedProperty in _hardCodedConfigPropertyCache) { - // Set the PropertyValue to the hard coded value + // Set the PropertyValue to the hard coded value. + // Deep-clone the value to ensure the cache stores independent copies of reference types + // (e.g. Dictionary<,>). Without cloning, in-place mutations to a static property like + // Application.DefaultKeyBindings (e.g. dict[cmd] = ...) would silently corrupt the + // cached "hard-coded default", causing test-order-dependent failures. hardCodedProperty.Value.Immutable = false; hardCodedProperty.Value.UpdateToCurrentValue (); + hardCodedProperty.Value.PropertyValue = DeepCloner.DeepClone (hardCodedProperty.Value.PropertyValue); hardCodedProperty.Value.Immutable = true; } }