Skip to content

Commit 45f719c

Browse files
CopilotJustinGrote
andauthored
Refine workspace document transition test semantics
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/f6b6da25-a6a1-4158-9738-3a65a7e3008e Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
1 parent cfead40 commit 45f719c

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

test/PowerShellEditorServices.Test/Extensions/EditorOperationsServiceTests.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,18 @@ public void GetWorkspaceOpenDocumentsTracksEditedAndUntitledSaveStates()
6868

6969
openSaved.ApplyChange(new FileChange
7070
{
71-
IsReload = true,
71+
Line = 1,
72+
Offset = 1,
73+
EndLine = 1,
74+
EndOffset = 1,
7275
InsertString = "Set-StrictMode -Version Latest"
7376
});
7477

7578
WorkspaceOpenDocument[] editedDocuments = editorOperationsService.GetWorkspaceOpenDocuments();
7679
Assert.Contains(editedDocuments, static document => document.Path.EndsWith("open-saved.ps1") && !document.Saved);
7780

78-
openSaved.IsInMemory = openSaved.IsUntitled;
79-
openUntitled.IsInMemory = openUntitled.IsUntitled;
81+
SimulateSaveReset(openSaved);
82+
SimulateSaveReset(openUntitled);
8083

8184
WorkspaceOpenDocument[] savedDocuments = editorOperationsService.GetWorkspaceOpenDocuments();
8285
Assert.Contains(savedDocuments, static document => document.Path.EndsWith("open-saved.ps1") && document.Saved);
@@ -88,5 +91,10 @@ private static ScriptFile CreateFileBuffer(WorkspaceService workspaceService, st
8891
string filePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"), fileName);
8992
return workspaceService.GetFileBuffer(DocumentUri.FromFileSystemPath(filePath), initialBuffer: string.Empty);
9093
}
94+
95+
private static void SimulateSaveReset(ScriptFile scriptFile)
96+
{
97+
scriptFile.IsInMemory = scriptFile.IsUntitled;
98+
}
9199
}
92100
}

0 commit comments

Comments
 (0)