Skip to content

Commit

Permalink
Fix #139786
Browse files Browse the repository at this point in the history
  • Loading branch information
lramos15 committed Feb 17, 2022
1 parent a34d50b commit 8437d74
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions extensions/vscode-api-tests/src/singlefolder-tests/window.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,42 @@ suite('vscode API - window', () => {

await group1Tabs[0].move(1, ViewColumn.One);
});

test('Tabs - vscode.open & vscode.diff', async function () {
// Simple function to get the active tab
const getActiveTab = () => {
return window.tabGroups.all.find(g => g.isActive)?.activeTab;
};

const [docA, docB, docC] = await Promise.all([
workspace.openTextDocument(await createRandomFile()),
workspace.openTextDocument(await createRandomFile()),
workspace.openTextDocument(await createRandomFile())
]);

await window.showTextDocument(docA, { viewColumn: ViewColumn.One, preview: false });
await window.showTextDocument(docB, { viewColumn: ViewColumn.One, preview: false });
await window.showTextDocument(docC, { viewColumn: ViewColumn.Two, preview: false });

const commandFile = await createRandomFile();
await commands.executeCommand('vscode.open', commandFile, ViewColumn.Three);
// Ensure active tab is correct after calling vscode.opn
assert.strictEqual(getActiveTab()?.viewColumn, ViewColumn.Three);

const leftDiff = await createRandomFile();
const rightDiff = await createRandomFile();
await commands.executeCommand('vscode.diff', leftDiff, rightDiff, 'Diff', { viewColumn: ViewColumn.Four, preview: false });
assert.strictEqual(getActiveTab()?.viewColumn, ViewColumn.Four);

const tabs = window.tabGroups.all.map(g => g.tabs).flat(1);
assert.strictEqual(tabs.length, 5);
assert.strictEqual(tabs[0].resource?.toString(), docA.uri.toString());
assert.strictEqual(tabs[1].resource?.toString(), docB.uri.toString());
assert.strictEqual(tabs[2].resource?.toString(), docC.uri.toString());
assert.strictEqual(tabs[3].resource?.toString(), commandFile.toString());

});

test('Tabs - Ensure tabs getter is correct', async function () {
// Reduce test timeout as this test should be quick, so even with 3 retries it will be under 60s.
this.timeout(10000);
Expand Down

0 comments on commit 8437d74

Please sign in to comment.