Skip to content

Commit c11dda5

Browse files
committed
Recognize debugger pseudo-commands
ValidateAndAcceptLine was rejecting debugger commands like 's' or 'k'. Now we check if we are debugging and accept these fake commands. Fixes #199
1 parent 51bc372 commit c11dda5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

PSReadLine/BasicEditing.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,28 @@ private bool UnresolvedCommandCouldSucceed(string commandName, Ast rootAst)
370370
}
371371
}
372372

373+
if (commandName.Length == 1)
374+
{
375+
switch (commandName[0])
376+
{
377+
// The following are debugger commands that should be accepted if we're debugging
378+
// because the console host will interpret these commands directly.
379+
case 's': case 'v': case 'o': case 'c': case 'q': case'k': case 'l':
380+
case 'S': case 'V': case 'O': case 'C': case 'Q': case'K': case 'L':
381+
case '?': case 'h': case 'H':
382+
// Ideally we would check $PSDebugContext, but it is set at function
383+
// scope, and because we're in a module, we can't find that variable
384+
// (arguably a PowerShell issue.)
385+
// NestedPromptLevel is good enough though - it's rare to be in a nested.
386+
var nestedPromptLevel = _engineIntrinsics.SessionState.PSVariable.GetValue("NestedPromptLevel");
387+
if (nestedPromptLevel is int)
388+
{
389+
return ((int)nestedPromptLevel) > 0;
390+
}
391+
break;
392+
}
393+
}
394+
373395
return false;
374396
}
375397

0 commit comments

Comments
 (0)