Skip to content

Commit e31213a

Browse files
committed
Add delay to prevent racing condition
1 parent 0982685 commit e31213a

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

src/test/suite/file_actions.test.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ suite('File Actions', () => {
336336
fileActions.handleRenameFileOrFolder({ id: 'abc', name: 'rename_file_or_folder', params: { oldPath: filePath, newPath: newFilePath } });
337337
await checkNoErrorWithTimeout(() => { verify(mockedClient.sendContext(anything())).once(); });
338338

339+
// Wait for the editor to update
340+
await new Promise(resolve => setTimeout(resolve, 200));
341+
339342
const uris = vscode.window.tabGroups.all.flatMap(group => group.tabs.map(tab => {
340343
if (tab.input instanceof vscode.TabInputText) {
341344
return tab.input.uri;
@@ -346,13 +349,8 @@ suite('File Actions', () => {
346349
// === Assert ===
347350
// Keep focus on the previously active editor (unrelated to the renamed file)
348351
assert.strictEqual(vscode.window.activeTextEditor?.document.uri.path.toLowerCase(), otherFileUri.path.toLowerCase(), 'The other file should still be active');
349-
// VS Code auto-remaps open tabs on rename. Desktop (file scheme) reliably closes the old tab;
350-
// in web/virtual FS the tab may transiently linger without breaking correctness. Only enforce on desktop.
351-
const workspaceScheme = vscode.workspace.workspaceFolders![0].uri.scheme;
352-
const isDesktop = workspaceScheme === 'file';
353-
if (isDesktop) {
354-
assert.strictEqual(uris.some(uri => uri.path.toLowerCase() === fileUri.path.toLowerCase()), false, 'The old file should not be open');
355-
}
352+
353+
assert.strictEqual(uris.some(uri => uri.path.toLowerCase() === fileUri.path.toLowerCase()), false, 'The old file should not be open');
356354
const newStat = await vscode.workspace.fs.stat(newFileUri);
357355
assert.strictEqual(newStat.type, vscode.FileType.File, 'The file should exist at the new path');
358356
});

0 commit comments

Comments
 (0)