From 3b9d917c6a0cf735b40804927799c4dbbee47b8c Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Tue, 14 Jan 2025 18:19:25 +0100 Subject: [PATCH 1/3] Properly handle exception from missing vscode config json file --- cursorless-talon/src/apps/vscode_settings.py | 1 - cursorless-talon/src/marks/decorated_mark.py | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cursorless-talon/src/apps/vscode_settings.py b/cursorless-talon/src/apps/vscode_settings.py index 9caa61c4ce..5f1ad84c42 100644 --- a/cursorless-talon/src/apps/vscode_settings.py +++ b/cursorless-talon/src/apps/vscode_settings.py @@ -61,7 +61,6 @@ def vscode_get_setting_with_fallback( return actions.user.vscode_get_setting(key, default_value), False except Exception: print(fallback_message) - traceback.print_exc() return fallback_value, True diff --git a/cursorless-talon/src/marks/decorated_mark.py b/cursorless-talon/src/marks/decorated_mark.py index 3592d4f6cc..1dd238f4a5 100644 --- a/cursorless-talon/src/marks/decorated_mark.py +++ b/cursorless-talon/src/marks/decorated_mark.py @@ -153,7 +153,11 @@ def setup_hat_styles_csv(hat_colors: dict[str, str], hat_shapes: dict[str, str]) def init_hats(hat_colors: dict[str, str], hat_shapes: dict[str, str]): setup_hat_styles_csv(hat_colors, hat_shapes) - vscode_settings_path: Path = actions.user.vscode_settings_path().resolve() + try: + vscode_settings_path: Path = actions.user.vscode_settings_path().resolve() + except Exception as ex: + print(ex) + return lambda: None def on_watch(path, flags): global fast_reload_job, slow_reload_job From fd9bea01f15f5c7d81e4aaf4c9c9499b4c51a046 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 17:22:42 +0000 Subject: [PATCH 2/3] [pre-commit.ci lite] apply automatic fixes --- cursorless-talon/src/apps/vscode_settings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cursorless-talon/src/apps/vscode_settings.py b/cursorless-talon/src/apps/vscode_settings.py index 5f1ad84c42..1700db7e48 100644 --- a/cursorless-talon/src/apps/vscode_settings.py +++ b/cursorless-talon/src/apps/vscode_settings.py @@ -1,5 +1,4 @@ import os -import traceback from pathlib import Path from typing import Any From 81d5a5be112b99bd1e3cb0199b56e06a666be29a Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Tue, 14 Jan 2025 19:12:44 +0100 Subject: [PATCH 3/3] Clean up --- cursorless-talon/src/marks/decorated_mark.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cursorless-talon/src/marks/decorated_mark.py b/cursorless-talon/src/marks/decorated_mark.py index 1dd238f4a5..df219477f2 100644 --- a/cursorless-talon/src/marks/decorated_mark.py +++ b/cursorless-talon/src/marks/decorated_mark.py @@ -153,11 +153,12 @@ def setup_hat_styles_csv(hat_colors: dict[str, str], hat_shapes: dict[str, str]) def init_hats(hat_colors: dict[str, str], hat_shapes: dict[str, str]): setup_hat_styles_csv(hat_colors, hat_shapes) + vscode_settings_path: Path | None = None + try: - vscode_settings_path: Path = actions.user.vscode_settings_path().resolve() + vscode_settings_path = actions.user.vscode_settings_path().resolve() except Exception as ex: print(ex) - return lambda: None def on_watch(path, flags): global fast_reload_job, slow_reload_job @@ -170,10 +171,12 @@ def on_watch(path, flags): "10s", lambda: setup_hat_styles_csv(hat_colors, hat_shapes) ) - fs.watch(str(vscode_settings_path), on_watch) + if vscode_settings_path is not None: + fs.watch(vscode_settings_path, on_watch) def unsubscribe(): - fs.unwatch(str(vscode_settings_path), on_watch) + if vscode_settings_path is not None: + fs.unwatch(vscode_settings_path, on_watch) if unsubscribe_hat_styles is not None: unsubscribe_hat_styles()