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
18 changes: 18 additions & 0 deletions python/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ def test_multi_workspace_settings_include_defaults(self, mock_uris):
assert "args" in ws_settings
assert "importStrategy" in ws_settings

@patch("vscode_common_python_lsp.server.uris")
def test_workspace_without_filesystem_path_is_skipped(self, mock_uris):
mock_uris.to_fs_path.side_effect = lambda u: (
"/local-workspace" if u == "file:///local-workspace" else None
)
ts = _make_server()
ts.update_workspace_settings(
[
{"workspace": "file:///local-workspace", "args": []},
{"workspace": "pico:", "args": []},
]
)

assert len(ts.workspace_settings) == 1
settings = next(iter(ts.workspace_settings.values()))
assert settings["workspace"] == "file:///local-workspace"
assert settings["workspaceFS"]


class TestGetSettingsByPath:
def test_matches_closest_workspace(self):
Expand Down
8 changes: 7 additions & 1 deletion python/vscode_common_python_lsp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,14 @@ def update_workspace_settings(self, settings: list[dict[str, Any]] | None) -> No
return

for setting in settings:
workspace_path = uris.to_fs_path(setting["workspace"])
# Virtual workspace roots, such as "pico:", have no local
# filesystem path, so they cannot be registered here.
if workspace_path is None:
continue

key = normalize_path(
uris.to_fs_path(setting["workspace"]),
workspace_path,
resolve_symlinks=self.config.resolve_symlinks,
)
self.workspace_settings[key] = {
Expand Down
Loading