Skip to content

Commit a846faa

Browse files
committed
Adds helper to close a tab by uri
1 parent 769bf00 commit a846faa

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/system/-webview/vscode/tabs.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ import { Uri, window } from 'vscode';
33
import { areUrisEqual } from '../../uri';
44
import { isTrackableUri } from './uris';
55

6+
export async function closeTab(uri: Uri, preserveFocus?: boolean): Promise<void> {
7+
for (const group of window.tabGroups.all) {
8+
for (const tab of group.tabs) {
9+
if (!tabContainsUri(tab, uri)) continue;
10+
11+
await window.tabGroups.close(tab, preserveFocus);
12+
return;
13+
}
14+
}
15+
}
16+
617
export function getTabUri(tab: Tab | undefined): Uri | undefined {
718
const input = tab?.input;
819
if (input == null || typeof input !== 'object') return undefined;

0 commit comments

Comments
 (0)