Skip to content

Commit 973b2dc

Browse files
authored
release: 1.1.1 (#7)
* ci: separate ci scripts * feat: add close all deletes files support * release: 1.1.1
1 parent 1e93488 commit 973b2dc

File tree

7 files changed

+115
-27
lines changed

7 files changed

+115
-27
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- run: echo "nvmrc=$(cat .nvmrc)" >> $GITHUB_ENV
20+
id: nvmrc
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: 20
25+
cache: npm
26+
- run: npm ci
27+
- run: npm run build
28+
- run: npm run lint

.github/workflows/publish-extension.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
name: Publish extension
2+
13
on:
2-
push:
3-
branches:
4-
- main
4+
release:
5+
types: [published]
56
workflow_dispatch:
67

7-
name: Publish extension
8-
98
jobs:
109
publish-extension:
1110
runs-on: ubuntu-latest

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,26 @@ The age of the opened tabs is persisted when the workspace is closed, and resume
1212

1313
In addition to automatically archiving unused tabs, the extension provides the following commands.
1414

15-
### `Tab Archive: Archive as many tabs as possible`
15+
### `Tab Archive: Archive As Many Tabs As Possible`
1616

1717
Archive all tabs except the 5 (by default) most recently used ones, in each group. (It also doesn't archive tabs with changes, pinned tabs, and the active one.)
1818

19-
### `Tab Archive: List recently archived tabs`
19+
### `Tab Archive: List Recently Archived Tabs`
2020

2121
List the tabs that have been automatically archived since the workspace was opened. Use it to adjust the `tabarchive.numberOfTabsInGroup` and `tabarchive.tabAgeForAutomaticArchiving` settings if you find that tabs are archived more/less often than you wish.
2222

23-
### `Tab Archive: Clear archived tabs`
23+
### `Tab Archive: Clear All Archived Tabs`
2424

2525
Clear all archived tabs from memory and storage. This is useful when you want to start fresh and remove all previously archived tabs.
2626

27-
### `Tab Archive: Close all diff tabs`
27+
### `Tab Archive: Close All Diff Tabs`
2828

2929
Close all diff tabs in all tab groups. This is useful when you want to quickly clean up after reviewing multiple file changes.
3030

31+
### `Tab Archive: Close All Deleted File Tabs`
32+
33+
Close all tabs that reference files that no longer exist on disk. This is useful when you want to clean up tabs for files that have been deleted outside of VS Code.
34+
3135
## Configuration
3236

3337
For detailed information about all available settings, please see the [documentation](docs.md).

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Tab Archive",
44
"icon": "logo-220x220.png",
55
"description": "Unused tab archive",
6-
"version": "1.1.0",
6+
"version": "1.1.1",
77
"publisher": "guza",
88
"repository": "github:guuzaa/vscode-tabarchive",
99
"engines": {
@@ -73,7 +73,7 @@
7373
"commands": [
7474
{
7575
"command": "tabarchive.archiveAsManyTabsAsPossible",
76-
"title": "Tab Archive: Archive as many tabs as possible"
76+
"title": "Tab Archive: Archive As Many Tabs As Possible"
7777
},
7878
{
7979
"command": "tabarchive.activate",
@@ -85,15 +85,19 @@
8585
},
8686
{
8787
"command": "tabarchive.listArchivedTabs",
88-
"title": "Tab Archive: List recently archived tabs"
88+
"title": "Tab Archive: List Recently Archived Tabs"
8989
},
9090
{
9191
"command": "tabarchive.clearArchivedTabs",
92-
"title": "Tab Archive: Clear all archived tabs"
92+
"title": "Tab Archive: Clear All Archived Tabs"
9393
},
9494
{
9595
"command": "tabarchive.closeAllDiffTabs",
96-
"title": "Tab Archive: Close all diff tabs"
96+
"title": "Tab Archive: Close All Diff Tabs"
97+
},
98+
{
99+
"command": "tabarchive.closeAllDeletedFileTabs",
100+
"title": "Tab Archive: Close All Deleted File Tabs"
97101
}
98102
],
99103
"menus": {

src/extension.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ import * as vscode from "vscode";
22
import { INTERVAL_IN_MINUTES, lg } from "./common";
33
import { getSettingValue, updateSettingValue } from "./settings";
44
import {
5-
archiveTabs,
6-
clearArchivedTabs,
7-
closeAllDiffTabs,
8-
createTabTimeCounters,
9-
incrementTabTimeCounter,
10-
listArchivedTabs,
11-
loadArchivedTabs,
12-
removeTabTimeCounter,
13-
resetTabTimeCounter,
14-
storeArchivedTabs,
15-
storeTabTimeCounters,
5+
archiveTabs,
6+
clearArchivedTabs,
7+
closeAllDeletedFileTabs,
8+
closeAllDiffTabs,
9+
createTabTimeCounters,
10+
incrementTabTimeCounter,
11+
listArchivedTabs,
12+
loadArchivedTabs,
13+
removeTabTimeCounter,
14+
resetTabTimeCounter,
15+
storeArchivedTabs,
16+
storeTabTimeCounters,
1617
} from "./tabarchive";
1718

1819
let interval: ReturnType<typeof setInterval>;
@@ -141,6 +142,13 @@ const registerCommands = (context: vscode.ExtensionContext) => {
141142
() => closeAllDiffTabs(),
142143
),
143144
);
145+
146+
context.subscriptions.push(
147+
vscode.commands.registerCommand(
148+
"tabarchive.closeAllDeletedFileTabs",
149+
() => closeAllDeletedFileTabs(),
150+
),
151+
);
144152
};
145153

146154
const isActiveInWorkspace = (): boolean => {

src/tabarchive.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,48 @@ export const closeAllDiffTabs = () => {
362362
vscode.window.setStatusBarMessage('No diff tabs found to close.', STATUS_MESSAGE_TIMEOUT_MS);
363363
}
364364
};
365+
366+
export const closeAllDeletedFileTabs = async () => {
367+
lg("Closing all deleted file tabs...");
368+
369+
let closedCount = 0;
370+
371+
// Directly iterate through tab groups and close tabs with deleted files
372+
for (const tabGroup of vscode.window.tabGroups.all) {
373+
for (const tab of tabGroup.tabs) {
374+
// Check if this is a text editor tab
375+
if (tab.input instanceof vscode.TabInputText) {
376+
const uri = tab.input.uri;
377+
378+
// Skip untitled files
379+
if (uri.scheme === 'untitled') {
380+
continue;
381+
}
382+
383+
try {
384+
// Check if the file exists
385+
const stat = await vscode.workspace.fs.stat(uri);
386+
if (!stat) {
387+
// File doesn't exist, close the tab
388+
vscode.window.tabGroups.close(tab);
389+
closedCount++;
390+
}
391+
} catch (error) {
392+
// If we can't stat the file, it likely doesn't exist
393+
vscode.window.tabGroups.close(tab);
394+
closedCount++;
395+
}
396+
}
397+
}
398+
}
399+
400+
// Show appropriate message based on result
401+
if (closedCount > 0) {
402+
vscode.window.setStatusBarMessage(
403+
`Closed ${closedCount} deleted file tab${closedCount === 1 ? '' : 's'}.`,
404+
STATUS_MESSAGE_TIMEOUT_MS
405+
);
406+
} else {
407+
vscode.window.setStatusBarMessage('No deleted file tabs found to close.', STATUS_MESSAGE_TIMEOUT_MS);
408+
}
409+
};

0 commit comments

Comments
 (0)