Skip to content

Commit c8721ba

Browse files
CopilotJustinGrote
andauthored
Add ToString override for workspace documents
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/7e3e8a1d-f66b-4f87-8bde-eb0dd19f928c Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
1 parent ac47839 commit c8721ba

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/PowerShellEditorServices/Extensions/EditorWorkspace.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ internal EditorWorkspaceDocument(EditorWorkspace workspace, string path)
2121
/// </summary>
2222
public string Path { get; }
2323

24+
/// <summary>
25+
/// Gets the full path of this document.
26+
/// </summary>
27+
/// <returns>The full document path.</returns>
28+
public override string ToString() => Path;
29+
2430
/// <summary>
2531
/// Opens this document in the editor.
2632
/// </summary>

test/PowerShellEditorServices.Test/Extensions/EditorWorkspaceTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ public void DocumentOpenSaveAndCloseUseWorkspaceOperations()
5454
call => Assert.Equal("CloseFile:" + filePath, call));
5555
}
5656

57+
[Fact]
58+
public void DocumentToStringReturnsDocumentPath()
59+
{
60+
const string filePath = @"C:\test\file.ps1";
61+
TestEditorOperations editorOperations = new()
62+
{
63+
OpenDocumentPaths = new[] { filePath }
64+
};
65+
66+
EditorWorkspace workspace = new(editorOperations);
67+
EditorWorkspaceDocument document = Assert.Single(workspace.Documents);
68+
69+
Assert.Equal(filePath, document.ToString());
70+
}
71+
5772
private sealed class TestEditorOperations : IEditorOperations
5873
{
5974
public string[] OpenDocumentPaths { get; set; } = Array.Empty<string>();

0 commit comments

Comments
 (0)