|
10 | 10 |
|
11 | 11 | import sublime |
12 | 12 |
|
| 13 | +from ...settings import load_settings |
| 14 | + |
13 | 15 | HANDSHAKE = "tabstack-keystate 2" |
14 | 16 | DEFAULT_HELPER_PATH = "/usr/local/libexec/tabstack-keystate" |
15 | 17 | DEFAULT_CTRL_KEYS = ("leftctrl", "rightctrl") |
16 | 18 |
|
17 | 19 | _HANDSHAKE_PREFIX = "tabstack-keystate " |
18 | | -_SETTINGS_FILE = "TabStack.sublime-settings" |
19 | 20 | _SETTINGS_WATCH_KEY = "tab_stack_keystate_helper" |
20 | 21 | _PROBE_TIMEOUT_S = 2 |
21 | 22 | _EXIT_TIMEOUT_S = 1 |
@@ -52,14 +53,14 @@ def command(self) -> list[str]: |
52 | 53 |
|
53 | 54 |
|
54 | 55 | def helper_path() -> str: |
55 | | - path = sublime.load_settings(_SETTINGS_FILE).get("keystate_helper_path", DEFAULT_HELPER_PATH) |
| 56 | + path = load_settings().get("keystate_helper_path", DEFAULT_HELPER_PATH) |
56 | 57 | if not isinstance(path, str) or not path: |
57 | 58 | path = DEFAULT_HELPER_PATH |
58 | 59 | return os.path.expanduser(path) |
59 | 60 |
|
60 | 61 |
|
61 | 62 | def helper_ctrl_keys() -> tuple[str, ...]: |
62 | | - keys: object = sublime.load_settings(_SETTINGS_FILE).get("keystate_ctrl_keys") |
| 63 | + keys: object = load_settings().get("keystate_ctrl_keys") |
63 | 64 | if not isinstance(keys, list) or not keys: |
64 | 65 | return DEFAULT_CTRL_KEYS |
65 | 66 | # The helper validates the names against its allowlist and reports a usage error. |
@@ -191,7 +192,7 @@ def on_settings_changed() -> None: |
191 | 192 | if _helper_config() != _probed_config: |
192 | 193 | on_invalidated() |
193 | 194 |
|
194 | | - sublime.load_settings(_SETTINGS_FILE).add_on_change(_SETTINGS_WATCH_KEY, on_settings_changed) |
| 195 | + load_settings().add_on_change(_SETTINGS_WATCH_KEY, on_settings_changed) |
195 | 196 |
|
196 | 197 |
|
197 | 198 | def _invalidate_probe(probe: HelperProbe) -> None: |
@@ -333,6 +334,6 @@ def _terminate(self, process: subprocess.Popen[str]) -> None: |
333 | 334 |
|
334 | 335 | def plugin_unloaded() -> None: |
335 | 336 | global _on_invalidated |
336 | | - sublime.load_settings(_SETTINGS_FILE).clear_on_change(_SETTINGS_WATCH_KEY) |
| 337 | + load_settings().clear_on_change(_SETTINGS_WATCH_KEY) |
337 | 338 | _on_invalidated = None |
338 | 339 | reset_helper_probe() |
0 commit comments