@@ -226,30 +226,114 @@ define(function (require, exports, module) {
226226 expect ( $list . find ( ".directory" ) . length ) . toBe ( 0 ) ;
227227 } ) ;
228228
229- it ( "should show full path next to the file name when file is outside current project" , async function ( ) {
230- // Count currently opened files
229+ it ( "should show directory path for external files" , async function ( ) {
231230 var workingSetListItemCountBeforeTest = workingSetListItemCount ;
232231
233- // First we need to open another file
232+ // Open an external file (outside current project)
234233 await openAndMakeDirty ( externalProjectTestPath + "/test.js" ) ;
235234
236235 // Wait for file to be added to the working set
237236 await awaitsFor ( function ( ) { return workingSetListItemCount === workingSetListItemCountBeforeTest + 1 ; } ) ;
238237
239- // Two files with the same name file_one.js should be now opened
240238 var $list = testWindow . $ ( ".open-files-container > ul" ) ;
241- const fullPathSpan = $list . find ( ".directory" ) ;
242- expect ( fullPathSpan . length ) . toBe ( 1 ) ;
243- expect ( fullPathSpan [ 0 ] . innerHTML . includes ( Phoenix . app . getDisplayPath ( externalProjectTestPath ) ) ) . toBe ( true ) ;
239+ const directorySpan = $list . find ( ".directory" ) ;
244240
245- // Now close last opened file to hide the directories again
246- DocumentManager . getCurrentDocument ( ) . _markClean ( ) ; // so we can close without a save dialog
247- await awaitsForDone ( CommandManager . execute ( Commands . FILE_CLOSE ) , "timeout on FILE_CLOSE" , 1000 ) ;
241+ // Should show directory information for external files
242+ expect ( directorySpan . length ) . toBe ( 1 ) ;
248243
249- // there should be no more directories shown
244+ const displayedPath = directorySpan [ 0 ] . innerHTML ;
245+ expect ( displayedPath . length ) . toBeGreaterThan ( 0 ) ;
246+ expect ( displayedPath . includes ( " — " ) ) . toBe ( true ) ; // Should have the separator
247+
248+ // Should contain some path information
249+ const actualPath = testWindow . Phoenix . app . getDisplayPath ( externalProjectTestPath ) ;
250+ expect ( actualPath . length ) . toBeGreaterThan ( 0 ) ;
251+
252+ // Clean up
253+ DocumentManager . getCurrentDocument ( ) . _markClean ( ) ;
254+ await awaitsForDone ( CommandManager . execute ( Commands . FILE_CLOSE ) , "timeout on FILE_CLOSE" , 1000 ) ;
250255 expect ( $list . find ( ".directory" ) . length ) . toBe ( 0 ) ;
251256 } ) ;
252257
258+ it ( "should truncate very long external file paths with ellipsis" , async function ( ) {
259+ // Create platform-appropriate test paths
260+ var isWindows = testWindow . brackets . platform === "win" ;
261+ var separator = isWindows ? "\\" : "/" ;
262+
263+ // Test truncation algorithm with platform-specific long path
264+ var mockLongPath = isWindows ?
265+ "C:\\Users\\username\\very\\long\\path\\structure\\with\\many\\nested\\directories" :
266+ "/Users/username/very/long/path/structure/with/many/nested/directories" ;
267+
268+ var segments = mockLongPath . split ( / [ \/ \\ ] / ) . filter ( seg => seg . length > 0 ) ;
269+ expect ( segments . length ) . toBeGreaterThan ( 3 ) ; // Ensure we have a long path
270+
271+ // Test the truncation logic that WorkingSetView should use
272+ var rootDirName = segments [ 0 ] ? segments [ 0 ] : segments [ 1 ] ;
273+ var truncated = rootDirName + separator + "…" + separator + segments [ segments . length - 1 ] ;
274+
275+ // Verify truncation works correctly
276+ expect ( truncated . includes ( "…" ) ) . toBe ( true ) ;
277+ expect ( truncated . includes ( segments [ 0 ] ) ) . toBe ( true ) ;
278+ expect ( truncated . includes ( segments [ segments . length - 1 ] ) ) . toBe ( true ) ;
279+ expect ( truncated ) . not . toContain ( "very" + separator + "long" + separator + "path" ) ;
280+
281+ // Now test the actual WorkingSetView implementation with a guaranteed long path
282+ var workingSetListItemCountBeforeTest = workingSetListItemCount ;
283+
284+ // Mock Phoenix.app.getDisplayPath to return a platform-appropriate long path
285+ var originalGetDisplayPath = testWindow . Phoenix . app . getDisplayPath ;
286+ var mockLongDisplayPath = isWindows ?
287+ "C:\\Users\\TestUser\\Documents\\Very\\Long\\Project\\Structure\\Directory" :
288+ "/Users/TestUser/Documents/Very/Long/Project/Structure/Directory" ;
289+
290+ // Extract expected parts for assertions
291+ var mockSegments = mockLongDisplayPath . split ( / [ \/ \\ ] / ) . filter ( seg => seg . length > 0 ) ;
292+ var firstSegment = mockSegments [ 0 ] ;
293+ var lastSegment = mockSegments [ mockSegments . length - 1 ] ;
294+ var middleSegments = isWindows ? "Very\\Long\\Project\\Structure" : "Very/Long/Project/Structure" ;
295+
296+ testWindow . Phoenix . app . getDisplayPath = function ( path ) {
297+ if ( path . includes ( externalProjectTestPath ) ) {
298+ return mockLongDisplayPath ;
299+ }
300+ return originalGetDisplayPath . call ( this , path ) ;
301+ } ;
302+
303+ try {
304+ await openAndMakeDirty ( externalProjectTestPath + "/test.js" ) ;
305+
306+ // Wait for file to be added to the working set
307+ await awaitsFor ( function ( ) { return workingSetListItemCount === workingSetListItemCountBeforeTest + 1 ; } ) ;
308+
309+ var $list = testWindow . $ ( ".open-files-container > ul" ) ;
310+ const directorySpan = $list . find ( ".directory" ) ;
311+ expect ( directorySpan . length ) . toBe ( 1 ) ;
312+
313+ const displayedPath = directorySpan [ 0 ] . innerHTML ;
314+ expect ( displayedPath . includes ( " — " ) ) . toBe ( true ) ;
315+
316+ // This is the critical test - if truncation is working, it MUST contain ellipsis
317+ expect ( displayedPath . includes ( "…" ) ) . toBe ( true ) ;
318+
319+ // Should show first and last segments (platform-appropriate)
320+ expect ( displayedPath . includes ( firstSegment ) ) . toBe ( true ) ;
321+ expect ( displayedPath . includes ( lastSegment ) ) . toBe ( true ) ;
322+
323+ // Should NOT show the full middle path
324+ expect ( displayedPath . includes ( middleSegments ) ) . toBe ( false ) ;
325+
326+ // Clean up
327+ DocumentManager . getCurrentDocument ( ) . _markClean ( ) ;
328+ await awaitsForDone ( CommandManager . execute ( Commands . FILE_CLOSE ) , "timeout on FILE_CLOSE" , 1000 ) ;
329+ expect ( $list . find ( ".directory" ) . length ) . toBe ( 0 ) ;
330+
331+ } finally {
332+ // Restore original function
333+ testWindow . Phoenix . app . getDisplayPath = originalGetDisplayPath ;
334+ }
335+ } ) ;
336+
253337 it ( "should show different directory names, when two files of the same name are opened, located in folders with same name" , async function ( ) {
254338 // Count currently opened files
255339 var workingSetListItemCountBeforeTest = workingSetListItemCount ;
0 commit comments