Skip to content

Commit c7ac618

Browse files
authored
Merge pull request #188 from mathworks/test/save-point-followups
Close the real-tab test's teardown race, and say "a move" in EditStackCopy
2 parents 27d8a47 + f00cb28 commit c7ac618

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎src/host/settledSave.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class EditStackCopy extends EditStackIndex {
9393
/** Set by a save or a revert while `indexStale`: the next move tells VS Code. */
9494
private armed = false;
9595

96-
/** `lost`: a push VS Code would read as reaching the save point (see above). */
96+
/** `lost`: a move VS Code would read as reaching the save point (see above). */
9797
constructor(
9898
fromBackup = false,
9999
private readonly lost: () => void = () => {},

‎test-integration/suite/customEditorSavePoint.test.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,14 @@ suite('A real tab stays dirty after a save, an undo past it and a different edit
178178
assert.ok(await vscode.workspace.save(uri), 'the tab saved again');
179179
await waitFor('the save to make the tab clean', () => dirty() === false);
180180
} finally {
181-
// Closed without a prompt whatever it reads: the tab made active again, then reverted and closed.
181+
// Closed without a prompt whatever it reads. A dirty tab is saved first, which VS Code awaits, rather
182+
// than reverted: VS Code does not await a revert's read of the file, which the suite then removes.
183+
// Only a tab the save could not clean is reverted.
182184
if (tabOf(uri)) {
185+
if (tabOf(uri)?.isDirty) await vscode.workspace.save(uri);
183186
await vscode.commands.executeCommand('vscode.openWith', uri, kind.viewType);
184-
await vscode.commands.executeCommand('workbench.action.revertAndCloseActiveEditor');
185-
// Before the suite removes the file the revert reads.
187+
const close = tabOf(uri)?.isDirty ? 'workbench.action.revertAndCloseActiveEditor' : 'workbench.action.closeActiveEditor';
188+
await vscode.commands.executeCommand(close);
186189
await waitFor(`${kind.file}'s tab to close`, () => !tabOf(uri));
187190
}
188191
}

0 commit comments

Comments
 (0)