Skip to content

Commit 46195ed

Browse files
authored
release: 1.0.4
fix: use status bar messages instead
1 parent fc2a749 commit 46195ed

File tree

1 file changed

+19
-29
lines changed

1 file changed

+19
-29
lines changed

src/tabarchive.ts

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getSettingValue } from "./settings";
44

55
const TAB_TIME_COUNTERS_STORAGE_KEY = "tabTimeCounters";
66
const ARCHIVED_TABS_STORAGE_KEY = "archivedTabs";
7+
const STATUS_MESSAGE_TIMEOUT_MS = 3000;
78

89
interface TabTimeCounters {
910
[tabGroupId: number]: {
@@ -169,7 +170,7 @@ export const clearArchivedTabs = async (context: vscode.ExtensionContext) => {
169170
// Clear from workspace state
170171
try {
171172
await context.workspaceState.update(ARCHIVED_TABS_STORAGE_KEY, []);
172-
vscode.window.showInformationMessage("All archived tabs have been cleared.");
173+
vscode.window.setStatusBarMessage("All archived tabs have been cleared.", STATUS_MESSAGE_TIMEOUT_MS);
173174
} catch (error: unknown) {
174175
vscode.window.showErrorMessage(`Failed to clear archived tabs: ${error instanceof Error ? error.message : String(error)}`);
175176
}
@@ -332,35 +333,24 @@ export const closeAllDiffTabs = () => {
332333

333334
let closedCount = 0;
334335

335-
// Create a promise that will resolve after the operation completes
336-
const closeTabsPromise = new Promise<number>((resolve) => {
337-
vscode.window.tabGroups.all.forEach((tabGroup) => {
338-
tabGroup.tabs.forEach((tab) => {
339-
// Check if this is a diff editor tab
340-
if (tab.input instanceof vscode.TabInputTextDiff) {
341-
vscode.window.tabGroups.close(tab);
342-
closedCount++;
343-
}
344-
});
336+
// Directly iterate through tab groups and close diff tabs
337+
vscode.window.tabGroups.all.forEach((tabGroup) => {
338+
tabGroup.tabs.forEach((tab) => {
339+
// Check if this is a diff editor tab
340+
if (tab.input instanceof vscode.TabInputTextDiff) {
341+
vscode.window.tabGroups.close(tab);
342+
closedCount++;
343+
}
345344
});
346-
resolve(closedCount);
347345
});
348346

349-
// Create a timeout promise
350-
const timeoutPromise = new Promise<number>((_, reject) => {
351-
setTimeout(() => reject(new Error("Operation timed out")), 5000); // 5 second timeout
352-
});
353-
354-
// Race the promises
355-
Promise.race([closeTabsPromise, timeoutPromise])
356-
.then((count) => {
357-
if (count > 0) {
358-
vscode.window.showInformationMessage(`Closed ${count} diff tab${count === 1 ? '' : 's'}.`);
359-
} else {
360-
vscode.window.showInformationMessage('No diff tabs found to close.');
361-
}
362-
})
363-
.catch((error) => {
364-
vscode.window.showErrorMessage(`Failed to close diff tabs: ${error.message}`);
365-
});
347+
// Show appropriate message based on result
348+
if (closedCount > 0) {
349+
vscode.window.setStatusBarMessage(
350+
`Closed ${closedCount} diff tab${closedCount === 1 ? '' : 's'}.`,
351+
STATUS_MESSAGE_TIMEOUT_MS
352+
);
353+
} else {
354+
vscode.window.setStatusBarMessage('No diff tabs found to close.', STATUS_MESSAGE_TIMEOUT_MS);
355+
}
366356
};

0 commit comments

Comments
 (0)