@@ -44505,9 +44505,9 @@ define("extensionsIntegrated/TabBar/main", function (require, exports, module) {
4450544505 const _ = require("thirdparty/lodash");
4450644506 const AppInit = require("utils/AppInit");
4450744507 const MainViewManager = require("view/MainViewManager");
44508- const EditorManager = require("editor/EditorManager");
4450944508 const FileSystem = require("filesystem/FileSystem");
4451044509 const PreferencesManager = require("preferences/PreferencesManager");
44510+ const FileUtils = require("file/FileUtils");
4451144511 const CommandManager = require("command/CommandManager");
4451244512 const Commands = require("command/Commands");
4451344513 const DocumentManager = require("document/DocumentManager");
@@ -44635,16 +44635,20 @@ define("extensionsIntegrated/TabBar/main", function (require, exports, module) {
4463544635 const isPaneActive = (paneId === currentActivePane);
4463644636
4463744637 const isDirty = Helper._isFileModified(FileSystem.getFileForPath(entry.path));
44638+ const isPlaceholder = entry.isPlaceholder === true;
4463844639
44639- // create tab with active class
44640+ // create tab with all the appropriate classes
4464044641 const $tab = $(
4464144642 `<div class="tab
44642- ${isActive ? 'active' : ''}
44643- ${isDirty ? 'dirty' : ''}" data-path="${entry.path}" title="${entry.path}">
44644- <div class="tab-icon"></div>
44645- <div class="tab-name"></div>
44646- <div class="tab-close"><i class="fa-solid fa-times"></i></div>
44647- </div>`
44643+ ${isActive ? 'active' : ''}
44644+ ${isDirty ? 'dirty' : ''}
44645+ ${isPlaceholder ? 'placeholder' : ''}"
44646+ data-path="${entry.path}"
44647+ title="${entry.path}">
44648+ <div class="tab-icon"></div>
44649+ <div class="tab-name"></div>
44650+ <div class="tab-close"><i class="fa-solid fa-times"></i></div>
44651+ </div>`
4464844652 );
4464944653
4465044654 // Add the file icon
@@ -44673,6 +44677,13 @@ define("extensionsIntegrated/TabBar/main", function (require, exports, module) {
4467344677 $tab.addClass('active-in-inactive-pane');
4467444678 }
4467544679
44680+ // if this is a placeholder tab in inactive pane, we need to use the brown styling
44681+ // instead of the blue one for active tabs
44682+ if (isPlaceholder && isActive && !isPaneActive) {
44683+ $tab.removeClass('active');
44684+ $tab.addClass('active-in-inactive-pane');
44685+ }
44686+
4467644687 return $tab;
4467744688 }
4467844689
@@ -44718,17 +44729,78 @@ define("extensionsIntegrated/TabBar/main", function (require, exports, module) {
4471844729 // Get all files from the working set. refer to `global.js`
4471944730 getAllFilesFromWorkingSet();
4472044731
44721- // When there is only one file, we enforce the creation of the tab bar
44722- // this is done because, given the situation:
44723- // In a vertical split, when no files are present in 'second-pane' so the tab bar is hidden.
44724- // Now, when the user adds a file in 'second-pane', the tab bar should be shown but since updateTabs() only,
44725- // updates the tabs, so the tab bar never gets created.
44726- if (Global.firstPaneWorkingSet.length === 1 &&
44732+ // Check for active files not in working set in any pane
44733+ const activePane = MainViewManager.getActivePaneId();
44734+ const firstPaneFile = MainViewManager.getCurrentlyViewedFile("first-pane");
44735+ const secondPaneFile = MainViewManager.getCurrentlyViewedFile("second-pane");
44736+
44737+ // when a file is opened from the filetree and is not present in the working set, then it is a placeholder
44738+ let firstPanePlaceholder = null;
44739+ let secondPanePlaceholder = null;
44740+
44741+ // Check if active file in first pane is not in the working set
44742+ if (firstPaneFile &&
44743+ !Global.firstPaneWorkingSet.some(entry => entry.path === firstPaneFile.fullPath)) {
44744+ firstPanePlaceholder = {
44745+ path: firstPaneFile.fullPath,
44746+ name: firstPaneFile.name,
44747+ isPlaceholder: true,
44748+ displayName: firstPaneFile.name // for now we initialize with name, will check for duplicates later
44749+ };
44750+ }
44751+
44752+ // Check if active file in second pane is not in the working set
44753+ if (secondPaneFile &&
44754+ !Global.secondPaneWorkingSet.some(entry => entry.path === secondPaneFile.fullPath)) {
44755+ secondPanePlaceholder = {
44756+ path: secondPaneFile.fullPath,
44757+ name: secondPaneFile.name,
44758+ isPlaceholder: true,
44759+ displayName: secondPaneFile.name
44760+ };
44761+ }
44762+
44763+ // check for duplicate file names between placeholder tabs and working set entries
44764+ if (firstPanePlaceholder) {
44765+ // if any working set file has the same name as the placeholder
44766+ const hasDuplicate = Global.firstPaneWorkingSet.some(entry =>
44767+ entry.name === firstPanePlaceholder.name
44768+ );
44769+
44770+ if (hasDuplicate) {
44771+ // extract directory name from path
44772+ const path = firstPanePlaceholder.path;
44773+ const parentDir = FileUtils.getDirectoryPath(path);
44774+ const dirParts = parentDir.split("/");
44775+ const parentDirName = dirParts[dirParts.length - 2] || "";
44776+
44777+ // Update displayName with directory
44778+ firstPanePlaceholder.displayName = parentDirName + "/" + firstPanePlaceholder.name;
44779+ }
44780+ }
44781+
44782+ if (secondPanePlaceholder) {
44783+ const hasDuplicate = Global.secondPaneWorkingSet.some(entry =>
44784+ entry.name === secondPanePlaceholder.name
44785+ );
44786+
44787+ if (hasDuplicate) {
44788+ const path = secondPanePlaceholder.path;
44789+ const parentDir = FileUtils.getDirectoryPath(path);
44790+ const dirParts = parentDir.split("/");
44791+ const parentDirName = dirParts[dirParts.length - 2] || "";
44792+
44793+ secondPanePlaceholder.displayName = parentDirName + "/" + secondPanePlaceholder.name;
44794+ }
44795+ }
44796+
44797+ // Create tab bar if there's a placeholder or a file in the working set
44798+ if ((Global.firstPaneWorkingSet.length > 0 || firstPanePlaceholder) &&
4472744799 (!$('#phoenix-tab-bar').length || $('#phoenix-tab-bar').is(':hidden'))) {
4472844800 createTabBar();
4472944801 }
4473044802
44731- if (Global.secondPaneWorkingSet.length === 1 &&
44803+ if (( Global.secondPaneWorkingSet.length > 0 || secondPanePlaceholder) &&
4473244804 (!$('#phoenix-tab-bar-2').length || $('#phoenix-tab-bar-2').is(':hidden'))) {
4473344805 createTabBar();
4473444806 }
@@ -44737,7 +44809,7 @@ define("extensionsIntegrated/TabBar/main", function (require, exports, module) {
4473744809 // Update first pane's tabs
4473844810 if ($firstTabBar.length) {
4473944811 $firstTabBar.empty();
44740- if (Global.firstPaneWorkingSet.length > 0) {
44812+ if (Global.firstPaneWorkingSet.length > 0 || firstPanePlaceholder ) {
4474144813
4474244814 // get the count of tabs that we want to display in the tab bar (from preference settings)
4474344815 // from preference settings or working set whichever smaller
@@ -44751,57 +44823,52 @@ define("extensionsIntegrated/TabBar/main", function (require, exports, module) {
4475144823
4475244824 let displayedEntries = Global.firstPaneWorkingSet.slice(0, tabsCountP1);
4475344825
44754- const activeEditor = EditorManager.getActiveEditor();
44755- const activePath = activeEditor ? activeEditor.document.file.fullPath : null;
44756- if (activePath && !displayedEntries.some(entry => entry.path === activePath)) {
44757- let activeEntry = Global.firstPaneWorkingSet.find(entry => entry.path === activePath);
44758- if (activeEntry) {
44759- displayedEntries[displayedEntries.length - 1] = activeEntry;
44760- }
44761- }
44826+ // Add working set tabs
4476244827 displayedEntries.forEach(function (entry) {
4476344828 $firstTabBar.append(createTab(entry, "first-pane"));
4476444829 });
44830+
44831+ // Add placeholder tab if needed
44832+ if (firstPanePlaceholder) {
44833+ $firstTabBar.append(createTab(firstPanePlaceholder, "first-pane"));
44834+ }
4476544835 }
4476644836 }
4476744837
4476844838 const $secondTabBar = $('#phoenix-tab-bar-2');
4476944839 // Update second pane's tabs
4477044840 if ($secondTabBar.length) {
4477144841 $secondTabBar.empty();
44772- if (Global.secondPaneWorkingSet.length > 0) {
44842+ if (Global.secondPaneWorkingSet.length > 0 || secondPanePlaceholder ) {
4477344843
4477444844 let tabsCountP2 = Math.min(Global.secondPaneWorkingSet.length, Preference.tabBarNumberOfTabs);
4477544845 if (Preference.tabBarNumberOfTabs < 0) {
4477644846 tabsCountP2 = Global.secondPaneWorkingSet.length;
4477744847 }
4477844848
4477944849 let displayedEntries2 = Global.secondPaneWorkingSet.slice(0, tabsCountP2);
44780- const activeEditor = EditorManager.getActiveEditor();
44781- const activePath = activeEditor ? activeEditor.document.file.fullPath : null;
44782- if (activePath && !displayedEntries2.some(entry => entry.path === activePath)) {
44783- let activeEntry = Global.secondPaneWorkingSet.find(entry => entry.path === activePath);
44784- if (activeEntry) {
44785- displayedEntries2[displayedEntries2.length - 1] = activeEntry;
44786- }
44787- }
44850+
44851+ // Add working set tabs
4478844852 displayedEntries2.forEach(function (entry) {
4478944853 $secondTabBar.append(createTab(entry, "second-pane"));
4479044854 });
44855+
44856+ // Add placeholder tab if needed
44857+ if (secondPanePlaceholder) {
44858+ $secondTabBar.append(createTab(secondPanePlaceholder, "second-pane"));
44859+ }
4479144860 }
4479244861 }
4479344862
44794- // if no files are present in a pane, we want to hide the tab bar for that pane
44795- if (Global.firstPaneWorkingSet.length === 0 && ($('#phoenix-tab-bar'))) {
44863+ // if no files are present in a pane and no placeholder , we want to hide the tab bar for that pane
44864+ if (Global.firstPaneWorkingSet.length === 0 && !firstPanePlaceholder && ($('#phoenix-tab-bar'))) {
4479644865 Helper._hideTabBar($('#phoenix-tab-bar'), $('#overflow-button'));
4479744866 }
4479844867
44799- if (Global.secondPaneWorkingSet.length === 0 && ($('#phoenix-tab-bar-2'))) {
44868+ if (Global.secondPaneWorkingSet.length === 0 && !secondPanePlaceholder && ($('#phoenix-tab-bar-2'))) {
4480044869 Helper._hideTabBar($('#phoenix-tab-bar-2'), $('#overflow-button-2'));
4480144870 }
4480244871
44803- const activePane = MainViewManager.getActivePaneId();
44804-
4480544872 // Now that tabs are updated, scroll to the active tab if necessary.
4480644873 if ($firstTabBar.length) {
4480744874 Overflow.toggleOverflowVisibility("first-pane");
@@ -44896,7 +44963,15 @@ define("extensionsIntegrated/TabBar/main", function (require, exports, module) {
4489644963 const currentActivePane = MainViewManager.getActivePaneId();
4489744964 const isPaneActive = (paneId === currentActivePane);
4489844965 const currentFile = MainViewManager.getCurrentlyViewedFile(currentActivePane);
44899- if(isPaneActive && currentFile && currentFile.fullPath === filePath) {
44966+
44967+ // Check if this is a placeholder tab
44968+ if ($(this).hasClass('placeholder')) {
44969+ // Add the file to the working set when placeholder tab is clicked
44970+ const fileObj = FileSystem.getFileForPath(filePath);
44971+ MainViewManager.addToWorkingSet(paneId, fileObj);
44972+ }
44973+
44974+ if (isPaneActive && currentFile && currentFile.fullPath === filePath) {
4490044975 return;
4490144976 }
4490244977 CommandManager.execute(Commands.FILE_OPEN, { fullPath: filePath, paneId: paneId });
@@ -45463,6 +45538,7 @@ define("extensionsIntegrated/TabBar/overflow", function (require, exports, modul
4546345538 name: $tab.find('.tab-name').text(),
4546445539 isActive: $tab.hasClass('active'),
4546545540 isDirty: $tab.hasClass('dirty'),
45541+ isPlaceholder: $tab.hasClass('placeholder'),
4546645542 $icon: $tab.find('.tab-icon').clone()
4546745543 };
4546845544
@@ -45536,17 +45612,22 @@ define("extensionsIntegrated/TabBar/overflow", function (require, exports, modul
4553645612 <i class="fa-solid fa-times"></i>
4553745613 </span>`;
4553845614
45615+ // add placeholder class to style it differently
45616+ const placeholderClass = item.isPlaceholder ? ' placeholder-name' : '';
45617+
4553945618 // return html for this item
4554045619 return {
4554145620 html:
45542- `<div class="dropdown-tab-item" data-tab-path="${item.path}">
45543- <div class="tab-info-container">
45544- ${dirtyHtml}
45545- <span class="tab-icon-container">${iconHtml}</span>
45546- <span class="tab-name-container">${item.name}</span>
45547- </div>
45548- ${closeIconHtml}
45549- </div>`,
45621+ `<div class="dropdown-tab-item${item.isPlaceholder
45622+ ? ' placeholder-item' : ''
45623+ }" data-tab-path="${item.path}">
45624+ <div class="tab-info-container">
45625+ ${dirtyHtml}
45626+ <span class="tab-icon-container">${iconHtml}</span>
45627+ <span class="tab-name-container${placeholderClass}">${item.name}</span>
45628+ </div>
45629+ ${closeIconHtml}
45630+ </div>`,
4555045631 enabled: true
4555145632 };
4555245633 });
@@ -45611,6 +45692,14 @@ define("extensionsIntegrated/TabBar/overflow", function (require, exports, modul
4561145692 // Set the active pane and open the file
4561245693 MainViewManager.setActivePaneId(paneId);
4561345694 CommandManager.execute(Commands.FILE_OPEN, { fullPath: filePath });
45695+
45696+ // get the tab bar element based on paneId and scroll to the active tab
45697+ // we use setTimeout to ensure that the DOM has updated after the file open command
45698+ setTimeout(function () {
45699+ const $tabBarElement = paneId === "first-pane" ?
45700+ $("#phoenix-tab-bar") : $("#phoenix-tab-bar-2");
45701+ scrollToActiveTab($tabBarElement);
45702+ }, 100);
4561445703 }
4561545704 });
4561645705
0 commit comments