-
Notifications
You must be signed in to change notification settings - Fork 33
Refactor: expandTilde dedup, USE_DEBUGPY gate, jsonrpc env+ConnectionError, _get_settings_by_path #466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Refactor: expandTilde dedup, USE_DEBUGPY gate, jsonrpc env+ConnectionError, _get_settings_by_path #466
Changes from all commits
6546275
ee74381
146902d
e429794
83bc685
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -697,6 +697,19 @@ def _get_settings_by_document(document: TextDocument | None): | |
| } | ||
|
|
||
|
|
||
| def _get_settings_by_path(file_path: pathlib.Path): | ||
| workspaces = {s["workspaceFS"] for s in WORKSPACE_SETTINGS.values()} | ||
|
|
||
| while file_path != file_path.parent: | ||
| str_file_path = utils.normalize_path(file_path) | ||
| if str_file_path in workspaces: | ||
| return WORKSPACE_SETTINGS[str_file_path] | ||
| file_path = file_path.parent | ||
|
|
||
| setting_values = list(WORKSPACE_SETTINGS.values()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copilot generated: Unguarded if not setting_values:
return {} # or raise a descriptive error |
||
| return setting_values[0] | ||
|
|
||
|
|
||
| # ***************************************************** | ||
| # Internal execution APIs. | ||
| # ***************************************************** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot generated:
-706
Key/value mismatch causes
KeyErroron happy path.workspacesis a set ofworkspaceFSfield values, butWORKSPACE_SETTINGS[str_file_path]indexes the dict by key. If the dict is keyed by URI (as is standard in LSP servers and consistent with sibling_get_settings_by_document), this crashes on every successful match.Fix: iterate items and match on value directly:
Or build a reverse mapping
{s["workspaceFS"]: s for s in WORKSPACE_SETTINGS.values()}.