Add client-side code folding fallback for virtual workspaces#5509
Draft
Copilot wants to merge 3 commits into
Draft
Add client-side code folding fallback for virtual workspaces#5509Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
6 tasks
Copilot
AI
changed the title
[WIP] Fix syntax-based code folding in virtual workspaces
Add client-side code folding fallback for virtual workspaces
Jun 10, 2026
Collaborator
|
@andyleejordan are we sure it can't run? Can't we treat the files like we do with untitled files and run analysis based on the contents? LSP 3.18 would be ideal for this but not strictly necessary, as long as we can get the content of the file from the virtual workspace and AST it. |
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.
In virtual workspaces (e.g. Azure DevOps / GitHub repos opened via Open Remote Repository), PowerShell Editor Services cannot run, so the LSP-powered syntax folding is unavailable and users lose code folding entirely once the workspace is trusted.
Changes
src/features/Folding.ts(new) — AFoldingRangeProviderthat ports the server'sTokenOperations.FoldableReferencesalgorithm to TypeScript: a tokenizer (braces, parens, here-strings, braced variables, block/line comments,#region/#endregion) plus the two-pass "largest range wins" folding logic. Registered only whenisVirtualWorkspace()is true, so it never competes with LSP folding in local workspaces.src/extension.ts— RegistersFoldingFeatureas a standalone (non-LSP) feature.package.json— Declares thevirtualWorkspacescapability as"limited", signaling partial support.test/features/Folding.test.ts(new) — Ports the PSES folding test corpus plus provider-level tests.Behavior notes
powershell.codeFolding.enable: when disabled, returns[]so VS Code falls back to indentation-based folding.powershell.codeFolding.showLastLine(decrements each region's end line by one to match the server).FoldingRangeAPI; character offsets from PSES are retained internally for test parity.This is intentionally partial support — features requiring PowerShell execution (debugging, terminals, analysis) remain unavailable in virtual workspaces, as they need real local file paths.