diff --git a/default/input-methods/typing_setup.py b/default/input-methods/typing_setup.py index 3cd6f842..3595e31f 100644 --- a/default/input-methods/typing_setup.py +++ b/default/input-methods/typing_setup.py @@ -117,11 +117,12 @@ def save_inputs(selected, overrides=None): missing = [catalog.get(name, name) for name in selected if name not in available] 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. 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) - set_inputs(group, layout, items, input_items(items, selected, overrides)) def keyboard_values(selected): diff --git a/test/shell.d/typing-setup-checks.py b/test/shell.d/typing-setup-checks.py index 78fc4958..b1d07e84 100644 --- a/test/shell.d/typing-setup-checks.py +++ b/test/shell.d/typing-setup-checks.py @@ -36,7 +36,6 @@ class TypingSetupTest(unittest.TestCase): self.assertEqual(catalog["cz:qwerty"], "Czech") self.assertNotIn("az", catalog) self.assertEqual(catalog["latam"], "Spanish (Latin American)") - self.assertEqual(catalog["latam"], "Spanish (Latin American)") self.assertNotIn("us:intl", catalog) self.assertLess(len(catalog), 60) @@ -56,6 +55,14 @@ class TypingSetupTest(unittest.TestCase): self.assertEqual(typing.input_items(items, ["mozc"]), [["keyboard-us", ""], ["mozc", ""], ["keyboard-fr", ""]]) self.assertEqual(typing.input_items(items, ["pinyin", "hangul", "mozc"]), items + [["pinyin", ""]]) + def test_failed_input_save_leaves_fonts_alone(self): + with tempfile.TemporaryDirectory() as temporary: + before = ("Default", "us", [["keyboard-us", ""]]) + with patch.dict(os.environ, {"XDG_CONFIG_HOME": temporary}), patch.object(typing.setup, "live_group", return_value=before), patch.object(typing.setup, "available_methods", return_value=[["mozc", "Mozc"]]), patch.object(typing, "set_inputs", side_effect=RuntimeError("rejected")): + with self.assertRaises(RuntimeError): + typing.save_inputs(["mozc"]) + self.assertFalse((Path(temporary) / "fontconfig/conf.d/50-omarchy-input-method.conf").exists()) + 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())