Skip to content

Commit ffa44a9

Browse files
committed
Easier launching of the debugging when /waitForDebugger passed in.
OK been doing a lot of debugging of the debug adapater and this has been driving me crazy. Launch VSCode, open PS1 file so I can find the PID of the editor host. Then debug the script, hop over to VS attach to process, find the PID of the second host process (the debug instance) and attach. This new approach will just pop up a dialog box asking which instance of VS to use to debug. You can press NO to skip attaching the debugger and the script will continue to execute.
1 parent 2f7d0a3 commit ffa44a9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/PowerShellEditorServices.Host/Program.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ static void Main(string[] args)
2727
"/waitForDebugger",
2828
StringComparison.InvariantCultureIgnoreCase));
2929

30-
// Should we wait for the debugger before starting?
3130
if (waitForDebugger)
3231
{
33-
// Wait for 25 seconds and then continue
34-
int waitCountdown = 25;
35-
while (!Debugger.IsAttached && waitCountdown > 0)
32+
if (Debugger.IsAttached)
3633
{
37-
Thread.Sleep(1000);
38-
waitCountdown--;
34+
Debugger.Break();
35+
}
36+
else
37+
{
38+
Debugger.Launch();
3939
}
4040
}
4141
#endif

0 commit comments

Comments
 (0)