mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-09 20:44:03 -08:00
fix(pwsh): prevent a command from eating tail of a transient prompt
This commit is contained in:
parent
4291da4b5a
commit
063b95da25
|
@ -157,7 +157,9 @@ func (e *Engine) shouldFill(filler string, padLength int) (string, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
repeat := padLength / lenFiller
|
repeat := padLength / lenFiller
|
||||||
return strings.Repeat(filler, repeat), true
|
unfilled := padLength % lenFiller
|
||||||
|
text := strings.Repeat(filler, repeat) + strings.Repeat(" ", unfilled)
|
||||||
|
return text, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) getTitleTemplateText() string {
|
func (e *Engine) getTitleTemplateText() string {
|
||||||
|
@ -531,7 +533,7 @@ func New(flags *runtime.Flags) *Engine {
|
||||||
|
|
||||||
switch env.Shell() {
|
switch env.Shell() {
|
||||||
case shell.ELVISH:
|
case shell.ELVISH:
|
||||||
// In Elvish, continuous text is always cut off before the right-most cell on the terminal screen.
|
// In Elvish, a prompt line will always wrap when the cursor reaches the rightmost cell on the terminal screen.
|
||||||
// We have to reduce the terminal width by 1 so a right-aligned block will not be broken.
|
// We have to reduce the terminal width by 1 so a right-aligned block will not be broken.
|
||||||
eng.rectifyTerminalWidth(-1)
|
eng.rectifyTerminalWidth(-1)
|
||||||
case shell.PWSH, shell.PWSH5:
|
case shell.PWSH, shell.PWSH5:
|
||||||
|
|
|
@ -458,7 +458,18 @@ Example:
|
||||||
Set-PSReadLineOption -ExtraPromptLineCount (($standardOut | Measure-Object -Line).Lines - 1)
|
Set-PSReadLineOption -ExtraPromptLineCount (($standardOut | Measure-Object -Line).Lines - 1)
|
||||||
|
|
||||||
# The output can be multi-line, joining them ensures proper rendering.
|
# The output can be multi-line, joining them ensures proper rendering.
|
||||||
$standardOut -join "`n"
|
$output = $standardOut -join "`n"
|
||||||
|
|
||||||
|
if ($script:PromptType -eq 'transient') {
|
||||||
|
# Workaround to prevent a command from eating the tail of a transient prompt, when we're at the end of the line.
|
||||||
|
$command = ''
|
||||||
|
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$command, [ref]$null)
|
||||||
|
if ($command) {
|
||||||
|
$output += " `b`b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$output
|
||||||
|
|
||||||
# remove any posh-git status
|
# remove any posh-git status
|
||||||
$env:POSH_GIT_STATUS = $null
|
$env:POSH_GIT_STATUS = $null
|
||||||
|
|
Loading…
Reference in a new issue