Skip to content

Commit ef4a11e

Browse files
Properly handle exception from missing vscode config json file (#2728)
Today on main this exception is not caught and the Cursorless list containing all the scopes is not filled which means that Cursorless is not working if we can't find the vscode json config file. ## Checklist - [/] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent a7d3488 commit ef4a11e

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

cursorless-talon/src/apps/vscode_settings.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import traceback
32
from pathlib import Path
43
from typing import Any
54

@@ -61,7 +60,6 @@ def vscode_get_setting_with_fallback(
6160
return actions.user.vscode_get_setting(key, default_value), False
6261
except Exception:
6362
print(fallback_message)
64-
traceback.print_exc()
6563
return fallback_value, True
6664

6765

cursorless-talon/src/marks/decorated_mark.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,12 @@ def setup_hat_styles_csv(hat_colors: dict[str, str], hat_shapes: dict[str, str])
153153
def init_hats(hat_colors: dict[str, str], hat_shapes: dict[str, str]):
154154
setup_hat_styles_csv(hat_colors, hat_shapes)
155155

156-
vscode_settings_path: Path = actions.user.vscode_settings_path().resolve()
156+
vscode_settings_path: Path | None = None
157+
158+
try:
159+
vscode_settings_path = actions.user.vscode_settings_path().resolve()
160+
except Exception as ex:
161+
print(ex)
157162

158163
def on_watch(path, flags):
159164
global fast_reload_job, slow_reload_job
@@ -166,10 +171,12 @@ def on_watch(path, flags):
166171
"10s", lambda: setup_hat_styles_csv(hat_colors, hat_shapes)
167172
)
168173

169-
fs.watch(str(vscode_settings_path), on_watch)
174+
if vscode_settings_path is not None:
175+
fs.watch(vscode_settings_path, on_watch)
170176

171177
def unsubscribe():
172-
fs.unwatch(str(vscode_settings_path), on_watch)
178+
if vscode_settings_path is not None:
179+
fs.unwatch(vscode_settings_path, on_watch)
173180
if unsubscribe_hat_styles is not None:
174181
unsubscribe_hat_styles()
175182

0 commit comments

Comments
 (0)