Skip to content

Commit 12001d5

Browse files
committed
feat: implement close unmodified tabs feature
1 parent 233f29a commit 12001d5

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

src/extensionsIntegrated/TabBar/more-options.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ define(function (require, exports, module) {
88
const CommandManager = require("command/CommandManager");
99
const Commands = require("command/Commands");
1010
const FileSystem = require("filesystem/FileSystem");
11+
const MainViewManager = require("view/MainViewManager");
1112

13+
const Global = require("./global");
1214

1315
// List of items to show in the context menu
1416
// Strings defined in `src/nls/root/strings.js`
@@ -67,10 +69,37 @@ define(function (require, exports, module) {
6769
/**
6870
* "CLOSE UNMODIFIED TABS"
6971
* This will close all tabs that are not modified
70-
* TODO: implement the functionality
7172
*/
7273
function handleCloseUnmodifiedTabs() {
73-
// pass
74+
const paneList = MainViewManager.getPaneIdList();
75+
76+
// for the first pane
77+
if (paneList.length > 0 && Global.firstPaneWorkingSet.length > 0) {
78+
// get all those entries that are not dirty
79+
const unmodifiedEntries = Global.firstPaneWorkingSet.filter(entry => !entry.isDirty);
80+
81+
// close each unmodified file in the first pane
82+
unmodifiedEntries.forEach(entry => {
83+
const fileObj = FileSystem.getFileForPath(entry.path);
84+
CommandManager.execute(
85+
Commands.FILE_CLOSE,
86+
{ file: fileObj, paneId: "first-pane" }
87+
);
88+
});
89+
}
90+
91+
// for second pane
92+
if (paneList.length > 1 && Global.secondPaneWorkingSet.length > 0) {
93+
const unmodifiedEntries = Global.secondPaneWorkingSet.filter(entry => !entry.isDirty);
94+
95+
unmodifiedEntries.forEach(entry => {
96+
const fileObj = FileSystem.getFileForPath(entry.path);
97+
CommandManager.execute(
98+
Commands.FILE_CLOSE,
99+
{ file: fileObj, paneId: "second-pane" }
100+
);
101+
});
102+
}
74103
}
75104

76105

0 commit comments

Comments
 (0)