@@ -45112,6 +45112,8 @@ define("extensionsIntegrated/TabBar/more-options", function (require, exports, m
4511245112 const items = [
4511345113 Strings.CLOSE_TAB,
4511445114 Strings.CLOSE_ACTIVE_TAB,
45115+ Strings.CLOSE_TABS_TO_THE_LEFT,
45116+ Strings.CLOSE_TABS_TO_THE_RIGHT,
4511545117 Strings.CLOSE_ALL_TABS,
4511645118 Strings.CLOSE_UNMODIFIED_TABS,
4511745119 "---",
@@ -45154,46 +45156,132 @@ define("extensionsIntegrated/TabBar/more-options", function (require, exports, m
4515445156
4515545157 /**
4515645158 * "CLOSE ALL TABS"
45157- * This will close all tabs no matter whether they are in first pane or second pane
45159+ * This will close all tabs in the specified pane
45160+ *
45161+ * @param {String} paneId - the id of the pane ["first-pane", "second-pane"]
4515845162 */
45159- function handleCloseAllTabs() {
45160- CommandManager.execute(Commands.FILE_CLOSE_ALL);
45163+ function handleCloseAllTabs(paneId) {
45164+ if (!paneId) {
45165+ return;
45166+ }
45167+
45168+ let workingSet;
45169+ workingSet = paneId === "first-pane" ? Global.firstPaneWorkingSet : Global.secondPaneWorkingSet;
45170+ if (!workingSet || workingSet.length === 0) {
45171+ return;
45172+ }
45173+
45174+ // close each file in the pane, start from the rightmost [to avoid index shifts]
45175+ for (let i = workingSet.length - 1; i >= 0; i--) {
45176+ const fileObj = FileSystem.getFileForPath(workingSet[i].path);
45177+ CommandManager.execute(
45178+ Commands.FILE_CLOSE,
45179+ { file: fileObj, paneId: paneId }
45180+ );
45181+ }
4516145182 }
4516245183
4516345184
4516445185 /**
4516545186 * "CLOSE UNMODIFIED TABS"
45166- * This will close all tabs that are not modified
45187+ * This will close all tabs that are not modified in the specified pane
45188+ *
45189+ * @param {String} paneId - the id of the pane ["first-pane", "second-pane"]
4516745190 */
45168- function handleCloseUnmodifiedTabs() {
45169- const paneList = MainViewManager.getPaneIdList();
45191+ function handleCloseUnmodifiedTabs(paneId) {
45192+ if (!paneId) {
45193+ return;
45194+ }
45195+
45196+ let workingSet;
45197+ workingSet = paneId === "first-pane" ? Global.firstPaneWorkingSet : Global.secondPaneWorkingSet;
45198+ if (!workingSet || workingSet.length === 0) {
45199+ return;
45200+ }
45201+
45202+ // get all those entries that are not dirty
45203+ const unmodifiedEntries = workingSet.filter(entry => !entry.isDirty);
45204+
45205+ // close each unmodified file in the pane
45206+ for (let i = unmodifiedEntries.length - 1; i >= 0; i--) {
45207+ const fileObj = FileSystem.getFileForPath(unmodifiedEntries[i].path);
45208+ CommandManager.execute(
45209+ Commands.FILE_CLOSE,
45210+ { file: fileObj, paneId: paneId }
45211+ );
45212+ }
45213+ }
45214+
45215+
45216+ /**
45217+ * "CLOSE TABS TO THE LEFT"
45218+ * This function is responsible for closing all tabs to the left of the right-clicked tab
45219+ *
45220+ * @param {String} filePath - path of the file that was right-clicked
45221+ * @param {String} paneId - the id of the pane in which the file is present
45222+ */
45223+ function handleCloseTabsToTheLeft(filePath, paneId) {
45224+ if (!filePath) {
45225+ return;
45226+ }
45227+
45228+ let workingSet;
45229+ workingSet = paneId === "first-pane" ? Global.firstPaneWorkingSet : Global.secondPaneWorkingSet;
45230+ if (!workingSet) {
45231+ return;
45232+ }
45233+
45234+ // find the index of the current file in the working set
45235+ const currentIndex = workingSet.findIndex(entry => entry.path === filePath);
4517045236
45171- // for the first pane
45172- if (paneList.length > 0 && Global.firstPaneWorkingSet.length > 0) {
45173- // get all those entries that are not dirty
45174- const unmodifiedEntries = Global.firstPaneWorkingSet.filter(entry => !entry.isDirty);
45237+ if (currentIndex > 0) { // we only proceed if there are tabs to the left
45238+ // get all files to the left of the current file
45239+ const filesToClose = workingSet.slice(0, currentIndex);
4517545240
45176- // close each unmodified file in the first pane
45177- unmodifiedEntries.forEach(entry => {
45178- const fileObj = FileSystem.getFileForPath(entry .path);
45241+ // Close each file, starting from the rightmost [to avoid index shifts]
45242+ for (let i = filesToClose.length - 1; i >= 0; i--) {
45243+ const fileObj = FileSystem.getFileForPath(filesToClose[i] .path);
4517945244 CommandManager.execute(
4518045245 Commands.FILE_CLOSE,
45181- { file: fileObj, paneId: "first-pane" }
45246+ { file: fileObj, paneId: paneId }
4518245247 );
45183- });
45248+ }
4518445249 }
45250+ }
4518545251
45186- // for second pane
45187- if (paneList.length > 1 && Global.secondPaneWorkingSet.length > 0) {
45188- const unmodifiedEntries = Global.secondPaneWorkingSet.filter(entry => !entry.isDirty);
4518945252
45190- unmodifiedEntries.forEach(entry => {
45191- const fileObj = FileSystem.getFileForPath(entry.path);
45253+ /**
45254+ * "CLOSE TABS TO THE RIGHT"
45255+ * This function is responsible for closing all tabs to the right of the right-clicked tab
45256+ *
45257+ * @param {String} filePath - path of the file that was right-clicked
45258+ * @param {String} paneId - the id of the pane in which the file is present
45259+ */
45260+ function handleCloseTabsToTheRight(filePath, paneId) {
45261+ if (!filePath) {
45262+ return;
45263+ }
45264+
45265+ let workingSet;
45266+ workingSet = paneId === "first-pane" ? Global.firstPaneWorkingSet : Global.secondPaneWorkingSet;
45267+ if (!workingSet) {
45268+ return;
45269+ }
45270+
45271+ // get the index of the current file in the working set
45272+ const currentIndex = workingSet.findIndex(entry => entry.path === filePath);
45273+ // only proceed if there are tabs to the right
45274+ if (currentIndex !== -1 && currentIndex < workingSet.length - 1) {
45275+ // get all files to the right of the current file
45276+ const filesToClose = workingSet.slice(currentIndex + 1);
45277+
45278+ for (let i = filesToClose.length - 1; i >= 0; i--) {
45279+ const fileObj = FileSystem.getFileForPath(filesToClose[i].path);
4519245280 CommandManager.execute(
4519345281 Commands.FILE_CLOSE,
45194- { file: fileObj, paneId: "second-pane" }
45282+ { file: fileObj, paneId: paneId }
4519545283 );
45196- });
45284+ }
4519745285 }
4519845286 }
4519945287
@@ -45253,26 +45341,34 @@ define("extensionsIntegrated/TabBar/more-options", function (require, exports, m
4525345341 */
4525445342 function _handleSelection(index, filePath, paneId) {
4525545343 switch (index) {
45256- case 0:
45257- // Close tab (the one that was right-clicked)
45258- handleCloseTab(filePath, paneId);
45259- break;
45260- case 1:
45261- // Close active tab
45262- handleCloseActiveTab();
45263- break;
45264- case 2:
45265- // Close all tabs
45266- handleCloseAllTabs();
45267- break;
45268- case 3:
45269- // Close unmodified tabs
45270- handleCloseUnmodifiedTabs();
45271- break;
45272- case 5:
45273- // Reopen closed file
45274- reopenClosedFile();
45275- break;
45344+ case 0:
45345+ // Close tab (the one that was right-clicked)
45346+ handleCloseTab(filePath, paneId);
45347+ break;
45348+ case 1:
45349+ // Close active tab
45350+ handleCloseActiveTab();
45351+ break;
45352+ case 2:
45353+ // Close tabs to the left
45354+ handleCloseTabsToTheLeft(filePath, paneId);
45355+ break;
45356+ case 3:
45357+ // Close tabs to the right
45358+ handleCloseTabsToTheRight(filePath, paneId);
45359+ break;
45360+ case 4:
45361+ // Close all tabs
45362+ handleCloseAllTabs(paneId);
45363+ break;
45364+ case 5:
45365+ // Close unmodified tabs
45366+ handleCloseUnmodifiedTabs(paneId);
45367+ break;
45368+ case 6:
45369+ // Reopen closed file
45370+ reopenClosedFile();
45371+ break;
4527645372 }
4527745373 }
4527845374
@@ -45537,13 +45633,23 @@ define("extensionsIntegrated/TabBar/overflow", function (require, exports, modul
4553745633 return;
4553845634 }
4553945635
45540- // make sure there is an active editor
45636+ let activePath;
45637+
45638+ // get the active file
4554145639 const activeEditor = EditorManager.getActiveEditor();
45542- if (!activeEditor || !activeEditor.document || !activeEditor.document.file) {
45543- return;
45640+ if (activeEditor && activeEditor.document && activeEditor.document.file) {
45641+ activePath = activeEditor.document.file.fullPath;
45642+ } else {
45643+ // If there is no active editor, we need to check if its an image file
45644+ const currentFile = MainViewManager.getCurrentlyViewedFile();
45645+ if (currentFile) {
45646+ activePath = currentFile.fullPath;
45647+ } else {
45648+ // if not an image file, not a text file, we don't need to scroll
45649+ return;
45650+ }
4554445651 }
4554545652
45546- const activePath = activeEditor.document.file.fullPath;
4554745653 // get the active tab. the active tab is the tab that is currently open
4554845654 const $activeTab = $tabBarElement.find(`.tab[data-path="${activePath}"]`);
4554945655
@@ -103493,6 +103599,8 @@ define("nls/root/strings", {
103493103599 // Tab bar Strings
103494103600 "CLOSE_TAB": "Close Tab",
103495103601 "CLOSE_ACTIVE_TAB": "Close Active Tab",
103602+ "CLOSE_TABS_TO_THE_RIGHT": "Close Tabs to the Right",
103603+ "CLOSE_TABS_TO_THE_LEFT": "Close Tabs to the Left",
103496103604 "CLOSE_ALL_TABS": "Close All Tabs",
103497103605 "CLOSE_UNMODIFIED_TABS": "Close Unmodified Tabs",
103498103606 "REOPEN_CLOSED_FILE": "Reopen Closed File",
0 commit comments