From 50e69f42892fb201982982e3086786fa979bf6fe Mon Sep 17 00:00:00 2001 From: zhaojianyong Date: Mon, 25 May 2026 09:12:58 +0800 Subject: [PATCH] fix(settings): persist font size changes in Appearance theme editor (#1381) --- CHANGELOG.md | 4 ++++ TablePro/Theme/ThemeEngine.swift | 7 ++++++- .../Settings/Appearance/ThemeEditorFontsSection.swift | 1 - 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ced712dc7..0e8a58328 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Changing the editor or data grid font size in Appearance settings now applies immediately and persists across relaunch, instead of resetting and leaving orphan custom themes behind (#1381) + ## [0.43.3] - 2026-05-22 ### Fixed diff --git a/TablePro/Theme/ThemeEngine.swift b/TablePro/Theme/ThemeEngine.swift index 4fd55ffcc..948361bef 100644 --- a/TablePro/Theme/ThemeEngine.swift +++ b/TablePro/Theme/ThemeEngine.swift @@ -150,9 +150,14 @@ internal final class ThemeEngine { func saveUserTheme(_ theme: ThemeDefinition) throws { try ThemeStorage.saveUserTheme(theme) + + if let index = availableThemes.firstIndex(where: { $0.id == theme.id }) { + availableThemes[index] = theme + } else { + availableThemes.append(theme) + } reloadAvailableThemes() - // If editing the active theme, re-activate to apply changes if theme.id == activeTheme.id { activateTheme(theme) } diff --git a/TablePro/Views/Settings/Appearance/ThemeEditorFontsSection.swift b/TablePro/Views/Settings/Appearance/ThemeEditorFontsSection.swift index a5cd567dc..89c9b7fc3 100644 --- a/TablePro/Views/Settings/Appearance/ThemeEditorFontsSection.swift +++ b/TablePro/Views/Settings/Appearance/ThemeEditorFontsSection.swift @@ -123,7 +123,6 @@ struct ThemeEditorFontsSection: View { var copy = engine.duplicateTheme(base, newName: base.name + " (Custom)") mutate(©.fonts) try? engine.saveUserTheme(copy) - engine.activateTheme(copy) editingTheme = copy onThemeDuplicated?(copy) } else {