@@ -25,6 +25,7 @@ define(function (require, exports, module) {
2525 const MainViewManager = require ( "view/MainViewManager" ) ;
2626 const FileSystem = require ( "filesystem/FileSystem" ) ;
2727 const PreferencesManager = require ( "preferences/PreferencesManager" ) ;
28+ const FileUtils = require ( "file/FileUtils" ) ;
2829 const CommandManager = require ( "command/CommandManager" ) ;
2930 const Commands = require ( "command/Commands" ) ;
3031 const DocumentManager = require ( "document/DocumentManager" ) ;
@@ -236,7 +237,8 @@ define(function (require, exports, module) {
236237 firstPanePlaceholder = {
237238 path : firstPaneFile . fullPath ,
238239 name : firstPaneFile . name ,
239- isPlaceholder : true
240+ isPlaceholder : true ,
241+ displayName : firstPaneFile . name // for now we initialize with name, will check for duplicates later
240242 } ;
241243 }
242244
@@ -246,11 +248,46 @@ define(function (require, exports, module) {
246248 secondPanePlaceholder = {
247249 path : secondPaneFile . fullPath ,
248250 name : secondPaneFile . name ,
249- isPlaceholder : true
251+ isPlaceholder : true ,
252+ displayName : secondPaneFile . name
250253 } ;
251254 }
252255
253- // create the tab bar if there's a placeholder or a file in the working set
256+ // check for duplicate file names between placeholder tabs and working set entries
257+ if ( firstPanePlaceholder ) {
258+ // if any working set file has the same name as the placeholder
259+ const hasDuplicate = Global . firstPaneWorkingSet . some ( entry =>
260+ entry . name === firstPanePlaceholder . name
261+ ) ;
262+
263+ if ( hasDuplicate ) {
264+ // extract directory name from path
265+ const path = firstPanePlaceholder . path ;
266+ const parentDir = FileUtils . getDirectoryPath ( path ) ;
267+ const dirParts = parentDir . split ( "/" ) ;
268+ const parentDirName = dirParts [ dirParts . length - 2 ] || "" ;
269+
270+ // Update displayName with directory
271+ firstPanePlaceholder . displayName = parentDirName + "/" + firstPanePlaceholder . name ;
272+ }
273+ }
274+
275+ if ( secondPanePlaceholder ) {
276+ const hasDuplicate = Global . secondPaneWorkingSet . some ( entry =>
277+ entry . name === secondPanePlaceholder . name
278+ ) ;
279+
280+ if ( hasDuplicate ) {
281+ const path = secondPanePlaceholder . path ;
282+ const parentDir = FileUtils . getDirectoryPath ( path ) ;
283+ const dirParts = parentDir . split ( "/" ) ;
284+ const parentDirName = dirParts [ dirParts . length - 2 ] || "" ;
285+
286+ secondPanePlaceholder . displayName = parentDirName + "/" + secondPanePlaceholder . name ;
287+ }
288+ }
289+
290+ // Create tab bar if there's a placeholder or a file in the working set
254291 if ( ( Global . firstPaneWorkingSet . length > 0 || firstPanePlaceholder ) &&
255292 ( ! $ ( '#phoenix-tab-bar' ) . length || $ ( '#phoenix-tab-bar' ) . is ( ':hidden' ) ) ) {
256293 createTabBar ( ) ;
0 commit comments