|
8 | 8 | using System.Linq;
|
9 | 9 | using System.Management.Automation;
|
10 | 10 | using System.Management.Automation.Language;
|
| 11 | +using System.Reflection; |
11 | 12 | using System.Text;
|
12 | 13 | using System.Threading.Tasks;
|
13 | 14 | using Microsoft.PowerShell.EditorServices.Debugging;
|
@@ -41,6 +42,7 @@ public class DebugService
|
41 | 42 | private VariableContainerDetails globalScopeVariables;
|
42 | 43 | private VariableContainerDetails scriptScopeVariables;
|
43 | 44 | private StackFrameDetails[] stackFrameDetails;
|
| 45 | + private PropertyInfo invocationTypeScriptPositionProperty; |
44 | 46 |
|
45 | 47 | private static int breakpointHitCounter = 0;
|
46 | 48 |
|
@@ -81,6 +83,12 @@ public DebugService(
|
81 | 83 | this.powerShellContext.BreakpointUpdated += this.OnBreakpointUpdated;
|
82 | 84 |
|
83 | 85 | this.remoteFileManager = remoteFileManager;
|
| 86 | + |
| 87 | + this.invocationTypeScriptPositionProperty = |
| 88 | + typeof(InvocationInfo) |
| 89 | + .GetProperty( |
| 90 | + "ScriptPosition", |
| 91 | + BindingFlags.NonPublic | BindingFlags.Instance); |
84 | 92 | }
|
85 | 93 |
|
86 | 94 | #endregion
|
@@ -1100,6 +1108,22 @@ await this.remoteFileManager.FetchRemoteFile(
|
1100 | 1108 | this.powerShellContext.CurrentRunspace);
|
1101 | 1109 | }
|
1102 | 1110 |
|
| 1111 | + if (this.stackFrameDetails.Length > 0) |
| 1112 | + { |
| 1113 | + // Augment the top stack frame with details from the stop event |
| 1114 | + IScriptExtent scriptExtent = |
| 1115 | + this.invocationTypeScriptPositionProperty |
| 1116 | + .GetValue(e.InvocationInfo) as IScriptExtent; |
| 1117 | + |
| 1118 | + if (scriptExtent != null) |
| 1119 | + { |
| 1120 | + this.stackFrameDetails[0].StartLineNumber = scriptExtent.StartLineNumber; |
| 1121 | + this.stackFrameDetails[0].EndLineNumber = scriptExtent.EndLineNumber; |
| 1122 | + this.stackFrameDetails[0].StartColumnNumber = scriptExtent.StartColumnNumber; |
| 1123 | + this.stackFrameDetails[0].EndColumnNumber = scriptExtent.EndColumnNumber; |
| 1124 | + } |
| 1125 | + } |
| 1126 | + |
1103 | 1127 | // Notify the host that the debugger is stopped
|
1104 | 1128 | this.DebuggerStopped?.Invoke(
|
1105 | 1129 | sender,
|
|
0 commit comments