Skip to content

Conversation

AndreasArvidsson
Copy link
Member

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
  • [/] I have updated the docs and cheatsheet
  • [/] I have not broken the cheatsheet

@AndreasArvidsson AndreasArvidsson requested a review from a team as a code owner January 14, 2025 17:20
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.

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
try:
vscode_settings_path = actions.user.vscode_settings_path().resolve()
except Exception as ex:
print(ex)
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)

@AndreasArvidsson AndreasArvidsson added this pull request to the merge queue Jan 16, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 16, 2025
@AndreasArvidsson AndreasArvidsson added this pull request to the merge queue Jan 16, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 16, 2025
@AndreasArvidsson AndreasArvidsson added this pull request to the merge queue Jan 16, 2025
Merged via the queue into main with commit ef4a11e Jan 16, 2025
15 checks passed
@AndreasArvidsson AndreasArvidsson deleted the missingVscodeJson branch January 16, 2025 17:39
cursorless-bot pushed a commit that referenced this pull request Jan 16, 2025
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants