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:
1 parent
a494f21ab9
commit
fd0c47e157
2 files changed
+16
-4
No files matched your search
@@ -118,11 +118,16 @@ def save_inputs(selected, overrides=None):
|
|||||||
if missing:
|
if missing:
|
||||||
raise RuntimeError("Restart input after updating Omarchy to use: " + ", ".join(missing))
|
raise RuntimeError("Restart input after updating Omarchy to use: " + ", ".join(missing))
|
||||||
set_inputs(group, layout, items, input_items(items, selected, overrides))
|
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"))
|
config_home = Path(os.environ.get("XDG_CONFIG_HOME") or str(Path.home() / ".config"))
|
||||||
for name in selected:
|
try:
|
||||||
if name in setup.PRESETS:
|
for name in selected:
|
||||||
setup.font_default(config_home, name)
|
if name in setup.PRESETS:
|
||||||
|
setup.font_default(config_home, name)
|
||||||
|
except BaseException:
|
||||||
|
setup.live_set(group, layout, items)
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
def keyboard_values(selected):
|
def keyboard_values(selected):
|
||||||
|
|||||||
@@ -63,6 +63,13 @@ class TypingSetupTest(unittest.TestCase):
|
|||||||
typing.save_inputs(["mozc"])
|
typing.save_inputs(["mozc"])
|
||||||
self.assertFalse((Path(temporary) / "fontconfig/conf.d/50-omarchy-input-method.conf").exists())
|
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):
|
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:
|
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())
|
self.assertFalse(typing.configure_inputs())
|
||||||
|
|||||||
Reference in new issue
Block a user