Expose open LSP documents via $psEditor.Workspace.Documents#2285
Expose open LSP documents via $psEditor.Workspace.Documents#2285Copilot wants to merge 30 commits into
$psEditor.Workspace.Documents#2285Conversation
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/76ae345c-b025-4fa0-8a0c-f6f8fa243d80 Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
$psEditor.Workspace.Documents
|
@copilot add close method as well |
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/6a4ffcb3-ffa5-431d-8a79-d5c87df48a9c Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
Added Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot for the EditorWorkspaceDocument, add a custom ToString that emits the full path of the document. |
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/7e3e8a1d-f66b-4f87-8bde-eb0dd19f928c Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
Added Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot Add a Saved bool getter property that shows whether the document is saved or unsaved. Update the ToString to only show the filename and the status. Example ToString: "File1.cs" if saved, "File1.cs [Unsaved]" if unsaved. |
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/3e87bc0c-ffcc-4ce4-9b08-22d248a3f5db Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/3e87bc0c-ffcc-4ce4-9b08-22d248a3f5db Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
Implemented in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot test failure Failed! - Failed: 1, Passed: 211, Skipped: 1, Total: 213, Duration: 45 s - Microsoft.PowerShell.EditorServices.Test.dll (net8.0) |
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/6285ab7f-3d36-4174-84cd-57dcebf32386 Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/6285ab7f-3d36-4174-84cd-57dcebf32386 Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
Fixed in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
Exposes the set of LSP documents currently open in the workspace through $psEditor.Workspace.Documents, so PowerShell extension scripts can enumerate/save/close them. To do that, the PR re-purposes ScriptFile.IsInMemory as a "dirty" flag, introduces a new IsUntitled predicate for the original "non-file URI" meaning, adds a WorkspaceOpenDocument value type, and threads it through IEditorOperations / EditorOperationsService / EditorWorkspace.
Changes:
- Add
WorkspaceOpenDocumentand surface open documents viaEditorWorkspace.Documents, plusCloseFile/SaveFileoverloads taking aWorkspaceOpenDocument. - Change
ScriptFile.IsInMemoryfrom an immutable "untitled-URI" flag into a mutable dirty flag (set onApplyChange, reset on save), and addIsUntitledplus mutableIsOpen; updateTextDocumentHandlerclose/save logic accordingly. - Add
EditorWorkspaceTestsandEditorOperationsServiceTestscovering the new path, and (unrelated) replacesleep 5with a diagnostic-polling helper in the vim tests.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| src/PowerShellEditorServices/Extensions/IEditorOperations.cs | New public WorkspaceOpenDocument struct + interface method to enumerate open docs; turns on #nullable enable for the file. |
| src/PowerShellEditorServices/Extensions/EditorWorkspace.cs | Exposes Documents property and overloads of CloseFile/SaveFile taking a WorkspaceOpenDocument. |
| src/PowerShellEditorServices/Services/Extension/EditorOperationsService.cs | Implements GetWorkspaceOpenDocuments by filtering WorkspaceService.GetOpenedFiles() on IsOpen. |
| src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs | Re-purposes IsInMemory as a mutable dirty flag, adds IsUntitled, documents IsOpen, sets IsInMemory = true in ApplyChange. |
| src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs | Updates close decision to look at URI scheme directly; resets IsInMemory on save. |
| src/PowerShellEditorServices/Services/Workspace/WorkspaceService.cs | Logs success/failure of CloseFile. |
| test/PowerShellEditorServices.Test/Extensions/EditorWorkspaceTests.cs | New unit tests for EditorWorkspace.Documents and WorkspaceOpenDocument.ToString. |
| test/PowerShellEditorServices.Test/Extensions/EditorOperationsServiceTests.cs | New unit test that GetWorkspaceOpenDocuments returns only IsOpen files with correct Saved; tab-indented. |
| test/vim-test.vim / test/vim-simple-test.vim | Replace sleep 5 with a poll-for-diagnostics helper (unrelated to the PR's stated purpose). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…it again) Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/25fb4a4a-04f5-471e-93fa-82a0a9cdcd91 Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
Head branch was pushed to by a user without write access
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/f6b6da25-a6a1-4158-9738-3a65a7e3008e Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/f6b6da25-a6a1-4158-9738-3a65a7e3008e Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/f6b6da25-a6a1-4158-9738-3a65a7e3008e Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/f6b6da25-a6a1-4158-9738-3a65a7e3008e Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
EditorOperationsServiceTestscoverage for latest open-document saved/unsaved transitions