Skip to content

Support provider-backed workspace URIs via pspath#2136

Draft
dkattan wants to merge 4 commits into
PowerShell:mainfrom
dkattan:feature/get-content
Draft

Support provider-backed workspace URIs via pspath#2136
dkattan wants to merge 4 commits into
PowerShell:mainfrom
dkattan:feature/get-content

Conversation

@dkattan
Copy link
Copy Markdown
Contributor

@dkattan dkattan commented Feb 13, 2024

Summary

  • add pspath:// document support so provider-backed scripts can participate in workspace operations without pretending to be file:// paths
  • route provider-backed workspace enumeration and content reads through PowerShell cmdlets when a host is available
  • keep normal file-backed documents and workspace traversal on direct filesystem I/O to avoid cross-thread/apartment issues in ordinary editor requests
  • preserve untitled/notebook handling and watched-file reload behavior for non-file URIs
  • keep the workspace service surface synchronous and cover the provider-backed launch path in tests

Why

The goal of this branch is to let PSES honor custom PSProviders for workspace content while still behaving normally for ordinary files. The final shape is intentionally hybrid: provider-backed URIs use PowerShell so custom providers are respected, and file-backed URIs stay on the existing filesystem path to avoid regressions in debugger, symbol, and code lens flows.

This also supports web-based VS Code scenarios where the editor does not share the same filesystem as the language server. In that setup, an extension can contribute a VS Code FileProvider for pspath: while PSES loads a matching PSProvider in its runspace; both sides can point at the same backing persistence mechanism, such as an API, so the client and the language server address the same logical content.

Files changed

  • WorkspaceService adds pspath conversion helpers plus provider-backed enumeration/read support
  • ScriptFile explicitly recognizes supported URI schemes and treats only true in-memory schemes as untitled
  • DidChangeWatchedFilesHandler reloads content through the workspace service and handles non-file URIs more safely
  • tests cover provider-backed launch and updated URI classification

Validation

  • targeted provider-path unit coverage passes locally
  • current PR CI is green on Ubuntu, macOS, and Windows, along with the policy checks

@dkattan dkattan force-pushed the feature/get-content branch from 59af6f2 to 42c028f Compare February 14, 2024 17:01
@dkattan dkattan marked this pull request as ready for review February 14, 2024 19:55
@dkattan dkattan requested a review from a team February 14, 2024 19:55
@dkattan
Copy link
Copy Markdown
Contributor Author

dkattan commented Feb 14, 2024

@andyleejordan Curious your thoughts on this. It ended up being heavier-handed than I wanted with all the async changes, but I'm wondering if that would be desirable if I split it into a separate MR? I know @SeeminglyScience doesn't want me changing the public interfaces, but they likely should've been Task<> from the start, async or not.

@dkattan dkattan force-pushed the feature/get-content branch from 42c028f to e72a219 Compare February 15, 2024 17:41
@dkattan dkattan changed the title Asyncify WorkspaceService/Perform File IO operations through PowerShell Replaced WorkspaceFileSystemWrapper with Get-Content and Get-ChildItem Feb 15, 2024
@dkattan dkattan force-pushed the feature/get-content branch from 974e92e to 1faf9f2 Compare February 15, 2024 21:35
@dkattan dkattan changed the title Replaced WorkspaceFileSystemWrapper with Get-Content and Get-ChildItem Draft: Replaced WorkspaceFileSystemWrapper with Get-Content and Get-ChildItem Feb 15, 2024
@dkattan dkattan marked this pull request as draft February 15, 2024 21:36
@dkattan dkattan changed the title Draft: Replaced WorkspaceFileSystemWrapper with Get-Content and Get-ChildItem Replaced WorkspaceFileSystemWrapper with Get-Content and Get-ChildItem Feb 15, 2024
@SeeminglyScience
Copy link
Copy Markdown
Collaborator

I know @SeeminglyScience doesn't want me changing the public interfaces, but they likely should've been Task<> from the start, async or not.

Can you talk through what you're trying to solve? When you make a synchronous method return Task<> all you're really doing is requiring wrapper object be created that will be immediately discarded. It doesn't change the behavior at all if that's the assumption.

Rebase feature/get-content onto current upstream/main.

Keep WorkspaceService synchronous while routing file reads and workspace
enumeration through PowerShell when a host is available, add pspath URI
support, and cover provider-backed launching in tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dkattan dkattan force-pushed the feature/get-content branch from 7f57a6c to c942560 Compare May 19, 2026 16:32
@dkattan
Copy link
Copy Markdown
Contributor Author

dkattan commented May 19, 2026

Rebased this branch onto the current main and force-pushed feature/get-content at c9425602.

On the sync/async concern: I kept WorkspaceService synchronous and reused the current PsesInternalHost.InvokePSCommand(...) synchronous helpers instead of widening the API surface or asyncifying the workspace methods. The branch now routes file reads / workspace enumeration through PowerShell when a host is available, keeps the existing non-host fallback for current callers/tests, and preserves pspath support for provider-backed documents.

I also added targeted coverage for provider-backed launch (PSProviderPathsLaunchCorrectly) and scheme handling.

dkattan and others added 2 commits May 19, 2026 14:08
Allow TryGetFile() to return existing in-memory untitled documents.
This preserves the debugger's untitled script workflow while still letting
provider-backed paths flow through WorkspaceService.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use direct file I/O for file-backed documents and filesystem traversal for file-backed workspace folders, while preserving PowerShell-backed behavior for provider URIs. This avoids cross-thread/apartment host invocations for ordinary workspace requests and keeps provider-backed paths working.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dkattan dkattan changed the title Replaced WorkspaceFileSystemWrapper with Get-Content and Get-ChildItem Support provider-backed workspace URIs via pspath May 19, 2026
Comment thread test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs
Comment thread src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs
Comment thread src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs
Comment thread src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs
Comment thread src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs
Comment thread src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs
Add concrete input/output examples to the pspath helper methods called out in PR review comments so the document/path transformations are easier to follow.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants