-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
Background color goes beyond prompt after program execution #14686
Comments
@neur1n The repro steps you provided don't work. |
Sorry, here is the minimal configuration: if ($IsWindows -and (Get-ExecutionPolicy) -ne 'RemoteSigned') {
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm
}
function Invoke-Module ($name) {
if (Get-Module -ListAvailable -Name $name) {
Import-Module $name
} else {
Write-Host 'Installing missinged module ' $name '...'
Install-Module $name -Scope CurrentUser -AllowPrerelease -Force
}
}
Invoke-Module 'posh-git'
Invoke-Module 'PSReadLine'
$script:indicator = '' # u+e0b0
$script:vimode = '[I]'
$script:vicolor = [ConsoleColor]::Green
function OnViModeChange {
if ($args[0] -eq 'Command') {
$script:vimode = '[N]'
$script:vicolor = [ConsoleColor]::Red
} else {
$script:vimode = '[I]'
$script:vicolor = [ConsoleColor]::Green
}
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
}
Set-PSReadLineOption -EditMode Vi
Set-PSReadLineOption -ExtraPromptLineCount 2
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineOption -ViModeIndicator Script -ViModeChangeHandler $Function:OnViModeChange
function Prompt {
$Prompt = Write-Prompt "`n"
$Prompt += & $GitPromptScriptBlock
$Prompt += Write-Prompt "`n $script:vimode" -BackgroundColor $script:vicolor
$Prompt += Write-Prompt "$script:indicator" -ForegroundColor $script:vicolor
if ($Prompt) { "$Prompt " } else { " " }
} |
This comment has been minimized.
This comment has been minimized.
I tried running |
Not sure if related but I get the same kind of behavior with C# code ran in a PowerShell (Core & Legacy) console. Console.BackgroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.Black;
Console.Write("Hello World!");
Console.ResetColor();
Console.WriteLine(); Executing After resizing the shell window I get a full red line: |
@neur1n - Thank you for reporting this issue. The working group discussed this and it turns out to be an issue with Windows Terminal, which has been fixed in the latest WT preview: microsoft/terminal#11742 After testing, we could not reproduce in the latest terminal and suggest you attempt the operation again with the latest version of Terminal. |
Thanks for your effort! However, it seems that this issue starts to occur when the prompt hits the last line of the terminal (I'm using WT preview |
@neur1n Had the issue always happened when the prompt hit the last line of the terminal, or that's only the case with the latest WT version? I'm asking because I want to understand whether this is still a variant of the linked Windows Terminal issue. Your prompt configuration is too complex to reason what might be the cause -- several factors in play: |
This issue has been marked as "Waiting on Author" and has not had any activity for 7 day. It has been closed for housekeeping purposes. |
Reopen |
Sorry about my late response. My minimal ps1 file to reproduce the issue: function Invoke-Module ($name) {
if (Get-Module -ListAvailable -Name $name) {
Import-Module $name
} else {
Write-Host 'Installing missinged module ' $name '...'
Install-Module $name -Scope CurrentUser -AllowPrerelease -Force
}
}
Invoke-Module 'PSReadLine'
$script:indicator = ''
$script:vimode = '[I]'
$script:vicolor = [ConsoleColor]::Green
function OnViModeChange {
if ($args[0] -eq 'Command') {
$script:vimode = '[N]'
$script:vicolor = [ConsoleColor]::Red
} else {
$script:vimode = '[I]'
$script:vicolor = [ConsoleColor]::Green
}
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
}
Set-PSReadLineOption -EditMode Vi
Set-PSReadLineOption -ExtraPromptLineCount 2
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineOption -ViModeIndicator Script -ViModeChangeHandler $Function:OnViModeChange
function Prompt {
$Prompt = Write-Prompt "`n"
$Prompt += & $GitPromptScriptBlock
$Prompt += Write-Prompt "`n $script:vimode" -BackgroundColor $script:vicolor
$Prompt += Write-Prompt "$script:indicator" -ForegroundColor $script:vicolor
if ($Prompt) { "$Prompt " } else { " " }
} |
Steps to reproduce
Expected behavior
Actual behavior
Environment data
The text was updated successfully, but these errors were encountered: