From d95182f17cbb2591ee72eb1e15093fe36a674c48 Mon Sep 17 00:00:00 2001 From: maj00r Date: Tue, 3 Nov 2026 21:51:54 +0100 Subject: [PATCH] List a key taken out of eu07.ini once A uart or uarttune the settings no longer write was found missing twice, as a key of set length and as one the file had, and showed twice among the changes. --- StarterNG.Tests/SettingsStoreTests.cs | 12 ++++++++++++ StarterNG/Application/SettingsStore.cs | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/StarterNG.Tests/SettingsStoreTests.cs b/StarterNG.Tests/SettingsStoreTests.cs index c2b0169..66ce35c 100644 --- a/StarterNG.Tests/SettingsStoreTests.cs +++ b/StarterNG.Tests/SettingsStoreTests.cs @@ -319,6 +319,18 @@ public class SettingsStoreTests Assert.DoesNotContain(lines, l => l.StartsWith("uart ")); } + [Fact] + public void A_disabled_uart_is_one_change() + { + var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "uart COM3 57600 0.1\n")); + installation.SettingsStore.Load(); + installation.SettingsStore.Settings.UartEnabled = false; + + var changes = installation.SettingsStore.Changes(installation.SettingsStore.Settings); + + Assert.Equal(new IniChange("uart", "COM3 57600 0.1", null), Assert.Single(changes, c => c.Key == "uart")); + } + [Fact] public void The_graphics_card_choice_survives_a_round_trip() { diff --git a/StarterNG/Application/SettingsStore.cs b/StarterNG/Application/SettingsStore.cs index 4755f46..f538db1 100644 --- a/StarterNG/Application/SettingsStore.cs +++ b/StarterNG/Application/SettingsStore.cs @@ -289,6 +289,7 @@ public sealed class SettingsStore var now = Render(settings); var shown = _capture?.ShownUnlikeSettings ?? new Dictionary(); var changes = new List(); + var listed = new HashSet(StringComparer.OrdinalIgnoreCase); foreach (string key in SettingsSerializer.ObsoleteKeys) Add(key, null); @@ -325,7 +326,8 @@ public sealed class SettingsStore { // To the simulator a key past endconfig is not set yet, whatever it says. string? before = value is not null && _config.IsPastEnd(key) ? null : _config.GetRaw(key); - if (before != value) + // A key gone from the file can be found gone more ways than one. + if (before != value && listed.Add(key)) changes.Add(new IniChange(key, before, value)); } }