@@ -1017,40 +1017,49 @@ define(function (require, exports, module) {
10171017 let filePath = $li . data ( _FILE_KEY ) . fullPath ;
10181018 const io = externalProjectFiles . indexOf ( filePath ) ;
10191019 if ( io !== - 1 ) {
1020+ const displayPath = Phoenix . app . getDisplayPath ( filePath ) ;
10201021 let dirPath = path . dirname ( filePath ) ;
1021- // this will be displayed on hover
1022- const displayPath = Phoenix . app . getDisplayPath ( dirPath ) ;
1023-
1024- let separator ;
1025- if ( Phoenix . isNativeApp ) {
1026- separator = brackets . platform === "win" ? "\\" : "/" ;
1022+ // this will be displayed on hover GetDisplayPath returns
1023+ // windows: C://some/path , linux/mac: /some/path
1024+ // a relative path of the form `folder/file.txt` (no-leading slash) for fs access paths- /mnt/paths
1025+ // or virtual path if its a browser indexed db - backed path like /fs/virtual/path
1026+ const displayDirPath = Phoenix . app . getDisplayPath ( dirPath ) ;
1027+
1028+ let sep ;
1029+ if ( Phoenix . isNativeApp && brackets . platform === "win" ) {
1030+ sep = "\\" ;
10271031 } else {
1028- separator = "/" ;
1032+ sep = "/" ;
10291033 }
10301034
1031- let dirSplit = displayPath . split ( separator ) ;
1035+ // Split the path and filter out empty segments
1036+ let dirSplit = displayDirPath . split ( sep ) . filter ( segment => segment !== '' ) ;
10321037
1033- let truncatedPath = displayPath ; // truncatedPath value will be shown in the UI
1038+ let truncatedPath = displayDirPath ; // truncatedPath value will be shown in the UI
10341039 if ( dirSplit . length > 3 ) {
1035- let rootDirName ;
1036-
1037- if ( Phoenix . isNativeApp ) {
1038- // Desktop app paths
1039- // dirSplit[0] maybe empty sometimes for absolute paths on Linux/Mac eg: "/root/fs/path/to/file"
1040- rootDirName = dirSplit [ 0 ] ? dirSplit [ 0 ] : dirSplit [ 1 ] ;
1040+ const rootDirName = dirSplit [ 0 ] ;
1041+ const secondLastSegment = dirSplit [ dirSplit . length - 2 ] ;
1042+ const fileName = dirSplit [ dirSplit . length - 1 ] ;
1043+
1044+ if ( Phoenix . isNativeApp && brackets . platform === "win" ) {
1045+ // Eg: C:\\long\path\to\file.txt - > C:\\...\to\file.txt
1046+ truncatedPath = `${ rootDirName } :${ sep } ${ sep } \u2026${ sep } ${ secondLastSegment } ${ sep } ${ fileName } ` ;
1047+ } else if ( Phoenix . isNativeApp ) {
1048+ // an absolute path of the form /abs/path/to/file in linux/mac desktop
1049+ // Eg: /application/path/to/file.txt - > /application/.../to/file.txt
1050+ truncatedPath = `${ sep } ${ rootDirName } ${ sep } \u2026${ sep } ${ secondLastSegment } ${ sep } ${ fileName } ` ;
1051+ } else if ( ! Phoenix . isNativeApp && ! displayDirPath . startsWith ( '/' ) ) {
1052+ // browser fs access path: `folder/file.txt` (no-leading slash) fs access paths- /mnt/paths
1053+ // Eg: opened/folder/path/to/file.txt - > opened/.../to/file.txt (no-leading slash)
1054+ truncatedPath = `${ rootDirName } ${ sep } \u2026${ sep } ${ secondLastSegment } ${ sep } ${ fileName } ` ;
10411055 } else {
1042- // Browser paths - handle different formats
1043- if ( displayPath . startsWith ( '/' ) ) {
1044- // Internal/default projects: /fs/path/to/file
1045- // dirSplit[0] will be empty due to leading '/'
1046- rootDirName = dirSplit [ 1 ] || dirSplit [ 0 ] ;
1047- } else {
1048- // User-opened system folders: path/to/file (no leading '/')
1049- rootDirName = dirSplit [ 0 ] ;
1050- }
1056+ //this is an internal indexed db backed virtual path. This can only happen if we allow virtual
1057+ // project locations from one project to be opened in another. So just print the trim path
1058+ // path in this case. In future, when we add this support, the get display path fn should be
1059+ // modified to give somethings like what we do for fs access path.
1060+ // Eg: /application/path/to/file.txt - > /application/.../to/file.txt
1061+ truncatedPath = `${ sep } ${ rootDirName } ${ sep } \u2026${ sep } ${ secondLastSegment } ${ sep } ${ fileName } ` ;
10511062 }
1052-
1053- truncatedPath = rootDirName + separator + "\u2026" + separator + dirSplit [ dirSplit . length - 1 ] ;
10541063 }
10551064
10561065 const $dir = $ ( `<span title='${ displayPath } ' class='directory'/>` )
0 commit comments