diff options
Diffstat (limited to 'gui/internal/model/mainconf_test.go')
| -rw-r--r-- | gui/internal/model/mainconf_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gui/internal/model/mainconf_test.go b/gui/internal/model/mainconf_test.go index c77591c..bd7720e 100644 --- a/gui/internal/model/mainconf_test.go +++ b/gui/internal/model/mainconf_test.go @@ -167,3 +167,34 @@ func TestMainSettingRefusesAnUnknownHead(t *testing.T) { t.Error("an unknown setting was read") } } + +// TestClearingASettingKeepsTheRestOfItsLine: clearing removed whole lines, +// so a setting sharing a line with anything else took it too. The Settings +// window writes "(defaults\n (case ignore))" itself - the closing paren of +// defaults sits on the setting's line - so setting a value and putting it +// back to "default" broke the file it had just written, and every later +// change silently reverted. +func TestClearingASettingKeepsTheRestOfItsLine(t *testing.T) { + m, _, _ := mainConf(t, "(include \"dl\")\n") + if err := m.SetSetting("case", "ignore"); err != nil { + t.Fatal(err) + } + if err := m.SetSetting("case", ""); err != nil { + t.Fatal(err) + } + if diags := m.Check(); len(diags) > 0 { + t.Errorf("the text no longer loads after set-then-clear: %v\n%s", diags[0], m.Text) + } + + // The other half: a hand-written one-line (defaults ...). + m2, _, _ := mainConf(t, "(include \"dl\")\n(defaults (case ignore) (fold yes))\n") + if err := m2.SetSetting("case", ""); err != nil { + t.Fatal(err) + } + if !strings.Contains(m2.Text, "(fold yes)") { + t.Errorf("clearing (case ...) took (fold yes) from the same line:\n%s", m2.Text) + } + if diags := m2.Check(); len(diags) > 0 { + t.Errorf("the text no longer loads: %v\n%s", diags[0], m2.Text) + } +} |
