-
-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP allow prompt char > to reflect nesting level. #363
Conversation
To be a good prompt citizen in PowerShell, the > (or whatever prompt char) should be displayed once for nesting level 0, twice for nesting level 1, and so on. In order to make that happen, we have to allow for deferred expansion of the Prompt*Suffix settings. See https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/about/about_prompts for more details.
@@ -38,7 +38,7 @@ $poshGitPromptScriptBlock = $null | |||
|
|||
$currentPromptDef = if ($funcInfo = Get-Command prompt -ErrorAction SilentlyContinue) { $funcInfo.Definition } | |||
|
|||
# HACK: If prompt is missing, create a global one we can overwrite with Set-Item | |||
# HACK: If prompt is missing, create a global one we can overwrite with Set-Item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes GitHub diff gets a little whacked. I didn't change that line at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I was a bit puzzled on that one.
@@ -85,7 +85,7 @@ if (!$currentPromptDef -or ($currentPromptDef -eq $defaultPromptDef)) { | |||
} | |||
|
|||
$global:LASTEXITCODE = $origLastExitCode | |||
$promptSuffix | |||
$ExecutionContext.SessionState.InvokeCommand.ExpandString($promptSuffix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL
I probably would have done something way more involved like check if $promptSuffix
was a [ScriptBlock]
to execute every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I assume ExpandString
is available in PS v2?
Commit message style note: WIP PRs are 100% approved, but generally I would avoid "WIP" in commit messages unless you're planning to rewrite history before we actually review and merge the code. Which I'm totally fine with (in fact, clean history is encouraged!), if we communicate as such. Unclear if that's your intent here, so thought I'd mention it. |
Yes, I tested on v2 to make sure.
So don't use WIP in commit msg unless it really is WIP? :-) Sorry about that. I thought it would change because I was thinking of replacing Prompt*Suffix with PromptChar. But I've changed my mind since. |
To be a good prompt citizen in PowerShell, the > (or whatever prompt char) should be displayed once for nesting level 0, twice for nesting level 1, and so on.
In order to make that happen, we have to allow for deferred expansion of the Prompt*Suffix settings.
See https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/about/about_prompts for more details.