@@ -41,6 +41,8 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
4141import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
4242import { attachStylerCallback } from 'vs/platform/theme/common/styler' ;
4343import { INotificationService } from 'vs/platform/notification/common/notification' ;
44+ import { commonSuffixLength } from 'vs/base/common/strings' ;
45+ import { posix } from 'vs/base/common/path' ;
4446
4547const $ = dom . $ ;
4648
@@ -78,6 +80,26 @@ export function getContextForContributedActions(element: CallStackItem | null):
7880 return '' ;
7981}
8082
83+ export function getSpecificSourceName ( stackFrame : IStackFrame ) : string {
84+ // To reduce flashing of the path name and the way we fetch stack frames
85+ // We need to compute the source name based on the other frames in the stale call stack
86+ let callStack = ( < Thread > stackFrame . thread ) . getStaleCallStack ( ) ;
87+ callStack = callStack . length > 0 ? callStack : stackFrame . thread . getCallStack ( ) ;
88+ const otherSources = callStack . map ( sf => sf . source ) . filter ( s => s !== stackFrame . source ) ;
89+ let suffixLength = 0 ;
90+ otherSources . forEach ( s => {
91+ if ( s . name === stackFrame . source . name ) {
92+ suffixLength = Math . max ( suffixLength , commonSuffixLength ( stackFrame . source . uri . path , s . uri . path ) ) ;
93+ }
94+ } ) ;
95+ if ( suffixLength === 0 ) {
96+ return stackFrame . source . name ;
97+ }
98+
99+ const from = Math . max ( 0 , stackFrame . source . uri . path . lastIndexOf ( posix . sep , stackFrame . source . uri . path . length - suffixLength - 1 ) ) ;
100+ return ( from > 0 ? '...' : '' ) + stackFrame . source . uri . path . substr ( from ) ;
101+ }
102+
81103export class CallStackView extends ViewPane {
82104 private pauseMessage ! : HTMLSpanElement ;
83105 private pauseMessageLabel ! : HTMLSpanElement ;
@@ -582,7 +604,7 @@ class StackFramesRenderer implements ITreeRenderer<IStackFrame, FuzzyScore, ISta
582604 data . file . title += `\n${ stackFrame . source . raw . origin } ` ;
583605 }
584606 data . label . set ( stackFrame . name , createMatches ( element . filterData ) , stackFrame . name ) ;
585- data . fileName . textContent = stackFrame . getSpecificSourceName ( ) ;
607+ data . fileName . textContent = getSpecificSourceName ( stackFrame ) ;
586608 if ( stackFrame . range . startLineNumber !== undefined ) {
587609 data . lineNumber . textContent = `${ stackFrame . range . startLineNumber } ` ;
588610 if ( stackFrame . range . startColumn ) {
@@ -855,7 +877,7 @@ class CallStackAccessibilityProvider implements IListAccessibilityProvider<CallS
855877 return nls . localize ( 'threadAriaLabel' , "Thread {0}, callstack, debug" , ( < Thread > element ) . name ) ;
856878 }
857879 if ( element instanceof StackFrame ) {
858- return nls . localize ( 'stackFrameAriaLabel' , "Stack Frame {0}, line {1}, {2}, callstack, debug" , element . name , element . range . startLineNumber , element . getSpecificSourceName ( ) ) ;
880+ return nls . localize ( 'stackFrameAriaLabel' , "Stack Frame {0}, line {1}, {2}, callstack, debug" , element . name , element . range . startLineNumber , getSpecificSourceName ( element ) ) ;
859881 }
860882 if ( isDebugSession ( element ) ) {
861883 return nls . localize ( 'sessionLabel' , "Debug Session {0}" , element . getLabel ( ) ) ;
0 commit comments