Restore the input group when the font preference cannot be written

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Heinemeier HanssonandClaude Opus 5.5 committed 2026-10-11 07:16:36 +09:00
1 parent a494f21ab9
commit fd0c47e157
2 files changed
+16 -4

No files matched your search

+9 -4
View File
@@ -118,11 +118,16 @@ def save_inputs(selected, overrides=None):
if missing:
raise RuntimeError("Restart input after updating Omarchy to use: " + ", ".join(missing))
set_inputs(group, layout, items, input_items(items, selected, overrides))
# Only a saved engine claims the CJK font fallback.
# Only a saved engine claims the CJK font fallback, and a failed font write
# returns the group so the menu's restored checks stay true.
config_home = Path(os.environ.get("XDG_CONFIG_HOME") or str(Path.home() / ".config"))
for name in selected:
if name in setup.PRESETS:
setup.font_default(config_home, name)
try:
for name in selected:
if name in setup.PRESETS:
setup.font_default(config_home, name)
except BaseException:
setup.live_set(group, layout, items)
raise
def keyboard_values(selected):
+7
View File
@@ -63,6 +63,13 @@ class TypingSetupTest(unittest.TestCase):
typing.save_inputs(["mozc"])
self.assertFalse((Path(temporary) / "fontconfig/conf.d/50-omarchy-input-method.conf").exists())
def test_failed_font_write_restores_the_input_group(self):
before = [["keyboard-us", ""]]
with patch.object(typing.setup, "live_group", return_value=("Default", "us", before)), patch.object(typing.setup, "available_methods", return_value=[["mozc", "Mozc"]]), patch.object(typing, "set_inputs"), patch.object(typing.setup, "font_default", side_effect=OSError("read-only")), patch.object(typing.setup, "live_set") as setter:
with self.assertRaises(OSError):
typing.save_inputs(["mozc"])
setter.assert_called_once_with("Default", "us", before)
def test_cancellation_does_not_change_input_settings(self):
with patch.object(typing.setup, "live_group", return_value=("Default", "us", [["keyboard-us", ""]])), patch.object(typing, "input_catalog", return_value=({"mozc": "Japanese"}, {"mozc": "Japanese"})), patch.object(typing, "choose", return_value=None), patch.object(typing.setup, "live_set") as setter:
self.assertFalse(typing.configure_inputs())