Support multi-root Pydance workspaces#38
Open
ankitchouhan1020 wants to merge 5 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pydance is a VS Code extension backed by the
pylightLSP server. Its main feature is workspace-wide Python symbol search: VS Code sendsworkspace/symbolrequests, andpylightanswers from an in-memory index built at server startup and kept fresh by file watchers.Before this change, Pydance only indexed the single legacy
rootUrifrom LSP initialization. In a VS Code multi-root workspace like:only the top/root repo was indexed. Symbols from the other workspace folders were missing from
Go to Symbol in Workspace/workspace/symbolresults.After this change,
pylightreadsInitializeParams.workspaceFoldersand indexes every folder VS Code sends. It still falls back torootUrifor normal single-folder workspaces, so existing single-repo behavior stays unchanged.Behavior changes
IgnoreFilter, so each repo's.gitignoreand default Python ignores apply relative to that repo.Pydance: Restart Serverso local testing can force a fresh LSP process and reindex without reloading the whole VS Code window.0.3.1for the local extension update.Example
Given a workspace with two folders:
{ "workspaceFolders": [ { "uri": "file:///path/repo-a", "name": "repo-a" }, { "uri": "file:///path/repo-b", "name": "repo-b" } ] }Pydance now:
/path/repo-a/path/repo-bworkspace/symbolIf VS Code only sends the legacy single-root shape:
{ "rootUri": "file:///path/repo-a" }Pydance keeps the old behavior and indexes only
/path/repo-a.Extension test coverage
A new VS Code integration runner opens a real multi-root
.code-workspacefixture while the existing single-root integration runner remains unchanged:That exercises the full headless VS Code path in CI:
pylightserver indexes both workspace folders.vscode.executeWorkspaceSymbolProviderfinds symbols from the second workspace folder.Pydance: Restart Serveris executed and verified to reindex symbols after restart.The test runner also uses a short
/tmpuser-data-dir to avoid macOS IPC socket path-length failures when the repo path is long.Implementation notes
LspServernow storesworkspace_roots: Vec<PathBuf>instead of a single optional root.workspace_roots_from_initialize_paramsprefersworkspaceFoldersand falls back torootUri.IndexUpdater::new_multicarries multiple roots and matching ignore filters.FileWatcherno longer owns a single-root ignore filter; it delegates watch decisions to the event handler, which has the multi-root context.Pydance: Restart Serverstops the currentLanguageClient, recreates it with the existing server/client options, reapplies trace config, and starts it again.Test plan
cd pylight && cargo test --quietcd pydance && npm run compilecd pydance && npm run compile:testscd pydance && npm run test:integrationcd pydance && npm run test:integration:multi-roottoughtype.pydance-0.3.1Pydance: Restart Serveris available and restarts/reindexes locallyNot included
Dynamic workspace-folder add/remove handling after the LSP server has started is not included. Restarting the server covers that case for now; we can add
workspace/didChangeWorkspaceFolderssupport if that becomes important.