@@ -44521,24 +44521,26 @@ define("extensionsIntegrated/TabBar/main", function (require, exports, module) {
4452144521 const MoreOptions = require("./more-options");
4452244522 const Overflow = require("./overflow");
4452344523 const DragDrop = require("./drag-drop");
44524- const TabBarHTML = `<div id="tab-bar-container" class="tab-bar-container">
44524+ const TabBarHTML = `<div class="tab-bar-container">
4452544525 <div id="phoenix-tab-bar" class="phoenix-tab-bar">
4452644526
4452744527 </div>
4452844528
4452944529 <div id="overflow-button" class="overflow-button" title="Show hidden tabs">
4453044530 <i class="fa-solid fa-chevron-down"></i>
4453144531 </div>
44532- </div>`;
44533- const TabBarHTML2 = `<div id="tab-bar-container" class="tab-bar-container">
44532+ </div>
44533+ `;
44534+ const TabBarHTML2 = `<div class="tab-bar-container">
4453444535 <div id="phoenix-tab-bar-2" class="phoenix-tab-bar">
4453544536
4453644537 </div>
4453744538
4453844539 <div id="overflow-button-2" class="overflow-button-2" title="Show hidden tabs">
4453944540 <i class="fa-solid fa-chevron-down"></i>
4454044541 </div>
44541- </div>`;
44542+ </div>
44543+ `;
4454244544
4454344545
4454444546
@@ -44686,21 +44688,22 @@ define("extensionsIntegrated/TabBar/main", function (require, exports, module) {
4468644688 // clean up any existing tab bars first and start fresh
4468744689 cleanupTabBar();
4468844690
44689- if ($('.not-editor').length === 1) {
44691+ const $paneHeader = $('.pane-header');
44692+ if ($paneHeader.length === 1) {
4469044693 $tabBar = $(TabBarHTML);
4469144694 // since we need to add the tab bar before the editor which has .not-editor class
44692- $(".not-editor ").before ($tabBar);
44695+ $(".pane-header ").after ($tabBar);
4469344696 WorkspaceManager.recomputeLayout(true);
4469444697 updateTabs();
4469544698
44696- } else if ($('.not-editor') .length === 2) {
44699+ } else if ($paneHeader .length === 2) {
4469744700 $tabBar = $(TabBarHTML);
4469844701 $tabBar2 = $(TabBarHTML2);
4469944702
4470044703 // eq(0) is for the first pane and eq(1) is for the second pane
4470144704 // TODO: Fix bug where the tab bar gets hidden inside the editor in horizontal split
44702- $(".not-editor"). eq(0).before ($tabBar);
44703- $(".not-editor"). eq(1).before ($tabBar2);
44705+ $paneHeader. eq(0).after ($tabBar);
44706+ $paneHeader. eq(1).after ($tabBar2);
4470444707 WorkspaceManager.recomputeLayout(true);
4470544708 updateTabs();
4470644709 }
@@ -44842,6 +44845,7 @@ define("extensionsIntegrated/TabBar/main", function (require, exports, module) {
4484244845 }
4484344846 // Also check for any orphaned tab bars that might exist
4484444847 $(".tab-bar-container").remove();
44848+ WorkspaceManager.recomputeLayout(true);
4484544849 }
4484644850
4484744851
@@ -44851,7 +44855,7 @@ define("extensionsIntegrated/TabBar/main", function (require, exports, module) {
4485144855 function handleTabClick() {
4485244856
4485344857 // delegate event handling for both tab bars
44854- $(document).on("click", ".tab", function (event) {
44858+ $(document).on("click", ".phoenix-tab-bar . tab", function (event) {
4485544859 // check if the clicked element is the close button
4485644860 if ($(event.target).hasClass('fa-times') || $(event.target).closest('.tab-close').length) {
4485744861 // Get the file path from the data-path attribute of the parent tab
@@ -44874,23 +44878,35 @@ define("extensionsIntegrated/TabBar/main", function (require, exports, module) {
4487444878 event.preventDefault();
4487544879 event.stopPropagation();
4487644880 }
44877- return;
4487844881 }
44882+ });
4487944883
44884+ // delegate event handling for both tab bars
44885+ $(document).on("mousedown", ".phoenix-tab-bar .tab", function (event) {
44886+ if ($(event.target).hasClass('fa-times') || $(event.target).closest('.tab-close').length) {
44887+ return;
44888+ }
4488044889 // Get the file path from the data-path attribute
4488144890 const filePath = $(this).attr("data-path");
4488244891
4488344892 if (filePath) {
44884- CommandManager.execute(Commands.FILE_OPEN, { fullPath: filePath });
44893+ // determine the pane inside which the tab belongs
44894+ const isSecondPane = $(this).closest("#phoenix-tab-bar-2").length > 0;
44895+ const paneId = isSecondPane ? "second-pane" : "first-pane";
44896+ const currentActivePane = MainViewManager.getActivePaneId();
44897+ const isPaneActive = (paneId === currentActivePane);
44898+ const currentFile = MainViewManager.getCurrentlyViewedFile(currentActivePane);
44899+ if(isPaneActive && currentFile && currentFile.fullPath === filePath) {
44900+ return;
44901+ }
44902+ CommandManager.execute(Commands.FILE_OPEN, { fullPath: filePath, paneId: paneId });
4488544903
44886- // Prevent default behavior
44887- event.preventDefault();
44888- event.stopPropagation();
44904+ // We dont prevent default behavior here to enable drag and drop of this tab
4488944905 }
4489044906 });
4489144907
4489244908 // Add the contextmenu (right-click) handler
44893- $(document).on("contextmenu", ".tab", function (event) {
44909+ $(document).on("contextmenu", ".phoenix-tab-bar . tab", function (event) {
4489444910 event.preventDefault();
4489544911 event.stopPropagation();
4489644912
@@ -44907,25 +44923,23 @@ define("extensionsIntegrated/TabBar/main", function (require, exports, module) {
4490744923 }
4490844924
4490944925
44926+ // debounce is used to prevent rapid consecutive calls to updateTabs,
44927+ // which was causing integration tests to fail in Firefox. Without it,
44928+ // the event fires too frequently when switching editors, leading to unexpected behavior
44929+ const debounceUpdateTabs = _.debounce(updateTabs, 2);
44930+
4491044931 /**
4491144932 * Registers the event handlers
4491244933 */
44913- function registerHandlers () {
44934+ function _registerHandlers () {
4491444935 // For pane layout changes, recreate the entire tab bar container
44915- MainViewManager.off("paneCreate paneDestroy paneLayoutChange", createTabBar);
4491644936 MainViewManager.on("paneCreate paneDestroy paneLayoutChange", createTabBar);
4491744937
4491844938 // For active pane changes, update only the tabs
44919- MainViewManager.off("activePaneChange", updateTabs);
4492044939 MainViewManager.on("activePaneChange", updateTabs);
4492144940
4492244941 // For editor changes, update only the tabs.
44923- EditorManager.off("activeEditorChange", updateTabs);
44924- // debounce is used to prevent rapid consecutive calls to updateTabs,
44925- // which was causing integration tests to fail in Firefox. Without it,
44926- // the event fires too frequently when switching editors, leading to unexpected behavior
44927- const debounceUpdateTabs = _.debounce(updateTabs, 2);
44928- EditorManager.on("activeEditorChange", debounceUpdateTabs);
44942+ MainViewManager.on(MainViewManager.EVENT_CURRENT_FILE_CHANGE, debounceUpdateTabs);
4492944943
4493044944 // For working set changes, update only the tabs.
4493144945 const events = [
@@ -45067,7 +45081,7 @@ define("extensionsIntegrated/TabBar/main", function (require, exports, module) {
4506745081 preferenceChanged();
4506845082
4506945083 // this should be called at the last as everything should be setup before registering handlers
45070- registerHandlers ();
45084+ _registerHandlers ();
4507145085
4507245086 // handle when a single tab gets clicked
4507345087 handleTabClick();
@@ -45110,15 +45124,13 @@ define("extensionsIntegrated/TabBar/more-options", function (require, exports, m
4511045124 const CommandManager = require("command/CommandManager");
4511145125 const Commands = require("command/Commands");
4511245126 const FileSystem = require("filesystem/FileSystem");
45113- const MainViewManager = require("view/MainViewManager");
4511445127
4511545128 const Global = require("./global");
4511645129
4511745130 // List of items to show in the context menu
4511845131 // Strings defined in `src/nls/root/strings.js`
4511945132 const items = [
4512045133 Strings.CLOSE_TAB,
45121- Strings.CLOSE_ACTIVE_TAB,
4512245134 Strings.CLOSE_TABS_TO_THE_LEFT,
4512345135 Strings.CLOSE_TABS_TO_THE_RIGHT,
4512445136 Strings.CLOSE_ALL_TABS,
@@ -45329,8 +45341,8 @@ define("extensionsIntegrated/TabBar/more-options", function (require, exports, m
4532945341 dropdown.showDropdown();
4533045342
4533145343 // handle the option selection
45332- dropdown.on("select", function (e, item, index ) {
45333- _handleSelection(index , filePath, paneId);
45344+ dropdown.on("select", function (e, item) {
45345+ _handleSelection(item , filePath, paneId);
4533445346 });
4533545347
4533645348 // Remove the button after the dropdown is hidden
@@ -45342,40 +45354,30 @@ define("extensionsIntegrated/TabBar/more-options", function (require, exports, m
4534245354 /**
4534345355 * Handles the selection of an option in the more options context menu
4534445356 *
45345- * @param {Number} index - the index of the selected option
45357+ * @param {String} item - the item being selected
4534645358 * @param {String} filePath - the path of the file that was right-clicked
4534745359 * @param {String} paneId - the id of the pane ["first-pane", "second-pane"]
4534845360 */
45349- function _handleSelection(index, filePath, paneId) {
45350- switch (index) {
45351- case 0:
45352- // Close tab (the one that was right-clicked)
45353- handleCloseTab(filePath, paneId);
45354- break;
45355- case 1:
45356- // Close active tab
45357- handleCloseActiveTab();
45358- break;
45359- case 2:
45360- // Close tabs to the left
45361- handleCloseTabsToTheLeft(filePath, paneId);
45362- break;
45363- case 3:
45364- // Close tabs to the right
45365- handleCloseTabsToTheRight(filePath, paneId);
45366- break;
45367- case 4:
45368- // Close all tabs
45369- handleCloseAllTabs(paneId);
45370- break;
45371- case 5:
45372- // Close unmodified tabs
45373- handleCloseUnmodifiedTabs(paneId);
45374- break;
45375- case 6:
45376- // Reopen closed file
45377- reopenClosedFile();
45378- break;
45361+ function _handleSelection(item, filePath, paneId) {
45362+ switch (item) {
45363+ case Strings.CLOSE_TAB:
45364+ handleCloseTab(filePath, paneId);
45365+ break;
45366+ case Strings.CLOSE_TABS_TO_THE_LEFT:
45367+ handleCloseTabsToTheLeft(filePath, paneId);
45368+ break;
45369+ case Strings.CLOSE_TABS_TO_THE_RIGHT:
45370+ handleCloseTabsToTheRight(filePath, paneId);
45371+ break;
45372+ case Strings.CLOSE_ALL_TABS:
45373+ handleCloseAllTabs(paneId);
45374+ break;
45375+ case Strings.CLOSE_UNMODIFIED_TABS:
45376+ handleCloseUnmodifiedTabs(paneId);
45377+ break;
45378+ case Strings.REOPEN_CLOSED_FILE:
45379+ reopenClosedFile();
45380+ break;
4537945381 }
4538045382 }
4538145383
@@ -103659,7 +103661,6 @@ define("nls/root/strings", {
103659103661
103660103662 // Tab bar Strings
103661103663 "CLOSE_TAB": "Close Tab",
103662- "CLOSE_ACTIVE_TAB": "Close Active Tab",
103663103664 "CLOSE_TABS_TO_THE_RIGHT": "Close Tabs to the Right",
103664103665 "CLOSE_TABS_TO_THE_LEFT": "Close Tabs to the Left",
103665103666 "CLOSE_ALL_TABS": "Close All Tabs",
@@ -103785,7 +103786,7 @@ define("nls/root/strings", {
103785103786 "CMD_HIDE_SIDEBAR": "Hide Sidebar",
103786103787 "CMD_SHOW_SIDEBAR": "Show Sidebar",
103787103788 "CMD_TOGGLE_SIDEBAR": "Toggle Sidebar",
103788- "CMD_TOGGLE_TABBAR": "Toggle Tab Bar",
103789+ "CMD_TOGGLE_TABBAR": "File Tab Bar",
103789103790 "CMD_TOGGLE_PANELS": "Toggle Panels",
103790103791 "CMD_TOGGLE_PURE_CODE": "No Distractions",
103791103792 "CMD_TOGGLE_FULLSCREEN": "Fullscreen",
@@ -171116,8 +171117,13 @@ define("view/Pane", function (require, exports, module) {
171116171117 * @private
171117171118 */
171118171119 Pane.prototype._updateHeaderHeight = function () {
171119- var paneContentHeight = this.$el.height();
171120+ const $el = this.$el;
171121+ const $tabBar = $el.find(".tab-bar-container");
171122+ let paneContentHeight = $el.height();
171120171123
171124+ if($tabBar.length > 0 && $tabBar.is(":visible")) {
171125+ paneContentHeight = paneContentHeight - $tabBar.height();
171126+ }
171121171127 // Adjust pane content height for header
171122171128 if (MainViewManager.getPaneCount() > 1) {
171123171129 this.$header.show();
0 commit comments