Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions cursorless-talon/src/apps/vscode_settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import traceback
from pathlib import Path
from typing import Any

Expand Down Expand Up @@ -61,7 +60,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()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just created a lot of noise in the Talon log. We know were the problem is without this.

return fallback_value, True


Expand Down
13 changes: 10 additions & 3 deletions cursorless-talon/src/marks/decorated_mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +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 = actions.user.vscode_settings_path().resolve()
vscode_settings_path: Path | None = None

try:
vscode_settings_path = actions.user.vscode_settings_path().resolve()
except Exception as ex:
print(ex)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the exception that was uncaught and broke Cursorless logic further up the call stack.

Comment on lines +158 to +161
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try:
vscode_settings_path = actions.user.vscode_settings_path().resolve()
except Exception as ex:
print(ex)
try:
vscode_settings_path = actions.user.vscode_settings_path().resolve()
except Exception as e:
print(f"Could not resolve VS Code settings path at {vscode_settings_path} (not fatal): {e}")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to avoid just doing raw printing of exception objects, because then you see the exception message in the log without much context / able to debug them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception message is already well formed
2025-01-16 18:00:29.801 IO Couldn't find VSCode's settings JSON. Tried these paths: C:\Users\andre\AppData\Roaming\Code2\User\settings.json, C:\Users\andre\AppData\Roaming\VSCodium\User\settings.json

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's defined here

def pick_path(paths: list[Path]) -> Path:
existing_paths = [path for path in paths if path.exists()]
if not existing_paths:
paths_str = ", ".join(str(path) for path in paths)
raise FileNotFoundError(
f"Couldn't find VSCode's settings JSON. Tried these paths: {paths_str}"
)
return max(existing_paths, key=lambda path: path.stat().st_mtime)


def on_watch(path, flags):
global fast_reload_job, slow_reload_job
Expand All @@ -166,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()

Expand Down
Loading