@@ -994,10 +994,45 @@ await _remoteFileManager.FetchRemoteFileAsync(
994
994
// Augment the top stack frame with details from the stop event
995
995
if ( invocationTypeScriptPositionProperty . GetValue ( e . InvocationInfo ) is IScriptExtent scriptExtent )
996
996
{
997
- stackFrameDetails [ 0 ] . StartLineNumber = scriptExtent . StartLineNumber ;
998
- stackFrameDetails [ 0 ] . EndLineNumber = scriptExtent . EndLineNumber ;
999
- stackFrameDetails [ 0 ] . StartColumnNumber = scriptExtent . StartColumnNumber ;
1000
- stackFrameDetails [ 0 ] . EndColumnNumber = scriptExtent . EndColumnNumber ;
997
+ StackFrameDetails targetFrame = stackFrameDetails [ 0 ] ;
998
+
999
+ // Certain context changes (like stepping into the default value expression
1000
+ // of a parameter) do not create a call stack frame. In order to represent
1001
+ // this context change we create a fake call stack frame.
1002
+ if ( ! string . IsNullOrEmpty ( scriptExtent . File )
1003
+ && ! PathUtils . IsPathEqual ( scriptExtent . File , targetFrame . ScriptPath ) )
1004
+ {
1005
+ await debugInfoHandle . WaitAsync ( ) . ConfigureAwait ( false ) ;
1006
+ try
1007
+ {
1008
+ targetFrame = new StackFrameDetails
1009
+ {
1010
+ ScriptPath = scriptExtent . File ,
1011
+ // Just use the last frame's variables since we don't have a
1012
+ // good way to get real values.
1013
+ AutoVariables = targetFrame . AutoVariables ,
1014
+ CommandVariables = targetFrame . CommandVariables ,
1015
+ // Ideally we'd get a real value here but since there's no real
1016
+ // call stack frame for this, we'd need to replicate a lot of
1017
+ // engine code.
1018
+ FunctionName = "<ScriptBlock>" ,
1019
+ } ;
1020
+
1021
+ StackFrameDetails [ ] newFrames = new StackFrameDetails [ stackFrameDetails . Length + 1 ] ;
1022
+ newFrames [ 0 ] = targetFrame ;
1023
+ stackFrameDetails . CopyTo ( newFrames , 1 ) ;
1024
+ stackFrameDetails = newFrames ;
1025
+ }
1026
+ finally
1027
+ {
1028
+ debugInfoHandle . Release ( ) ;
1029
+ }
1030
+ }
1031
+
1032
+ targetFrame . StartLineNumber = scriptExtent . StartLineNumber ;
1033
+ targetFrame . EndLineNumber = scriptExtent . EndLineNumber ;
1034
+ targetFrame . StartColumnNumber = scriptExtent . StartColumnNumber ;
1035
+ targetFrame . EndColumnNumber = scriptExtent . EndColumnNumber ;
1001
1036
}
1002
1037
}
1003
1038
0 commit comments