Skip to content
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

Using Backspace or Del Keys render as black box ! #14619

Closed
AnasTaherGit opened this issue Dec 30, 2022 · 6 comments
Closed

Using Backspace or Del Keys render as black box ! #14619

AnasTaherGit opened this issue Dec 30, 2022 · 6 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Product-Powershell Issues in the modern command interpreter, Powershell.exe. Resolution-External For issues that are outside this codebase Resolution-Fix-Available It's available in an Insiders build or a release

Comments

@AnasTaherGit
Copy link

Windows Terminal version

1.15.3466.0

Windows build number

No response

Other Software

No response

Steps to reproduce

I don't know the source of the bug it's just happening for me ! i just press backspace or del keys and it render as black box
and it happens only in powershell

Expected Behavior

When i press backspace or del key i expect to see blank space with my background in it

Actual Behavior

I got a black box and it appears as the whole background changed since if i rewrite a lettre it rendered on top of the black box

image

@AnasTaherGit AnasTaherGit added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Dec 30, 2022
@237dmitry
Copy link

237dmitry commented Dec 30, 2022

I think this is incorrect function prompt {} in powershell.

@AnasTaherGit
Copy link
Author

Here is the script of the prompt function i can't see where is the problem

 #store if the last command was successful
    $lastCommandSuccess = $?
    #store the last exit code for restore
    $realLASTEXITCODE = $global:LASTEXITCODE
    $omp = "C:/Users/cawoo/AppData/Local/oh-my-posh/oh-my-posh.exe"
    $config, $cleanPWD, $cleanPSWD = Get-PoshContext
    if ($env:POSH_TRANSIENT -eq $true) {
        $standardOut = @(&$omp --pwd="$cleanPWD" --pswd="$cleanPSWD" --config="$config" --print-transient 2>&1)
        $standardOut -join "`n"
        $env:POSH_TRANSIENT = $false
        return
    }
    $errorCode = 0
    Initialize-ModuleSupport
    Set-PoshContext
    if ($lastCommandSuccess -eq $false) {
        #native app exit code
        if ($realLASTEXITCODE -is [int] -and $realLASTEXITCODE -gt 0) {
            $errorCode = $realLASTEXITCODE
        }
        else {
            $errorCode = 1
        }
    }

    # read stack count from current stack(if invoked from profile=right value,otherwise use the global variable set in Set-PoshPrompt(stack scoped to module))
    $stackCount = (Get-Location -stack).Count
    try {
        if ($global:omp_global_sessionstate -ne $null) {
            $stackCount = ($global:omp_global_sessionstate).path.locationstack('').count
        }
    }
    catch {}

    $executionTime = -1
    $history = Get-History -ErrorAction Ignore -Count 1
    if ($null -ne $history -and $null -ne $history.EndExecutionTime -and $null -ne $history.StartExecutionTime -and $global:omp_lastHistoryId -ne $history.Id) {
        $executionTime = ($history.EndExecutionTime - $history.StartExecutionTime).TotalMilliseconds
        $global:omp_lastHistoryId = $history.Id
    }
    $terminalWidth = $Host.UI.RawUI.WindowSize.Width
    $standardOut = @(&$omp --error="$errorCode" --pwd="$cleanPWD" --pswd="$cleanPSWD" --execution-time="$executionTime" --stack-count="$stackCount" --config="$config" --terminal-width=$terminalWidth 2>&1)
    # make sure PSReadLine knows we have a multiline prompt
    $extraLines = $standardOut.Count - 1
    if ($extraLines -gt 0) {
        Set-PSReadlineOption -ExtraPromptLineCount $extraLines
    }
    # the output can be multiline, joining these ensures proper rendering by adding line breaks with `n
    $standardOut -join "`n"
    $global:LASTEXITCODE = $realLASTEXITCODE
    #remove temp variables
    Remove-Variable realLASTEXITCODE -Confirm:$false
    Remove-Variable lastCommandSuccess -Confirm:$false

@237dmitry
Copy link

I think you could try a powershell without the third party modules. What behavior if you run powershell -nop? There are too many questions for oh-my-posh.

@AnasTaherGit
Copy link
Author

I get the same behavior with -nop flag

image

@j4james
Copy link
Collaborator

j4james commented Dec 31, 2022

I believe this is the result of an old PSReadLine bug. You can see a similar report in #6767. If that is the case, you probably just need to upgrade the PSReadLine module to get it working correctly.

@zadjii-msft
Copy link
Member

Yea this is definitely an old PSReadline issue. Updating psreadline (and/or powershell to pwsh 7) will fix this.

@zadjii-msft zadjii-msft closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2023
@zadjii-msft zadjii-msft added Product-Powershell Issues in the modern command interpreter, Powershell.exe. Resolution-Fix-Available It's available in an Insiders build or a release Resolution-External For issues that are outside this codebase labels Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Product-Powershell Issues in the modern command interpreter, Powershell.exe. Resolution-External For issues that are outside this codebase Resolution-Fix-Available It's available in an Insiders build or a release
Projects
None yet
Development

No branches or pull requests

4 participants