Skip to content
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

fix: prevent AttributeError root_path when no workspace #396

Merged
merged 1 commit into from
Oct 6, 2023
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: 2 additions & 0 deletions pygls/workspace/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def __init__(
if root_path is None:
raise Exception("Couldn't get `root_path` from `root_uri`")
self._root_path = root_path
else:
self._root_path = None
self._sync_kind = sync_kind
self._text_documents: Dict[str, TextDocument] = {}
self._notebook_documents: Dict[str, types.NotebookDocument] = {}
Expand Down
7 changes: 7 additions & 0 deletions tests/test_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,10 @@ def test_workspace_folders():

assert workspace.folders["/ws/f1"] is wf1
assert workspace.folders["/ws/f2"] is wf2


def test_null_workspace():
workspace = Workspace(None)

assert workspace.root_uri is None
assert workspace.root_path is None