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
Unexpected backslash with OSC 9;9 prompt #3719
Comments
The issue is gone after Both PSReadline 2.2.6 and 2.3.1-beta1 have this issue. |
I had the exactly problem. In my case Set-PSReadlineOption -ContinuationPrompt $("`u{20}" * 5)
[console]::WriteLine("`e]12;#0087ff`a")
function Global:Prompt
{
$null = [int]::new() # No artefacts. I do not know why.
$prompt = "`e[38;5;31m `u{ff05} `e]9;9;${PWD}`e\`e[0m"
return $prompt
} |
You may want this instead of hacking around $normalPrompt = "`e[38;5;31m `u{ff05} `e[0m"
$errorPrompt = "`e[91m `u{ff05} `e[0m"
Set-PSReadlineOption -PromptText $normalPrompt, $errorPrompt From a comment in MicrosoftDocs/terminal#597 (comment),
I have no idea why hacking around |
Apparently PSReadLine simply cuts a substring since the last non-whitespace character in the prompt: https://github.com/PowerShell/PSReadLine/blob/v2.2.6/PSReadLine/ReadLine.cs#L819. It will be great if OSC commands are parsed and ignored, but that may be far from trivial due to the need of a parser of various escape sequences. If I were a PowerShell developer, I might close this as WONTFIX :)
|
No, I do not want. I showed this example to present a workaround that is inexplicable to me. |
I cannot reproduce the issue with the repro steps described in the issue. The GIF below is from WSL Ubuntu 18.04 with PowerShell 7.4-preview.3 + PSReadLine 2.3.1-beta1. I tried on Windows 11 with both conhost and Windows Terminal, and cannot reproduce too. @yan12125 and @237dmitry Can either of you please provide a repro that help me reproduce the issue locally? |
@daxian-dbw For me, the issue happens only when the prompt function is defined in Also, it seems that error prompt is not enabled for you (the last non-whitespace character should become red when there is a syntax error). Could you check if |
I can reproduce the issue after moving the prompt function to |
Thank you for confirmation. As the reproducer is from official Microsoft docs, how do you think about updating docs to work-around this issue first? MicrosoftDocs/terminal#689 |
Unfortunately, we don't own that doc. |
PSReadLine cuts a substring since the last non-whitespace character in the prompt as the error prompt [1], which is displayed when there are syntax errors. As a result, when the prompt ends in `$([char]27)\`, as in the previous example, an unexpected backslash may appear. See: PowerShell/PSReadLine#3719 [1] https://github.com/PowerShell/PSReadLine/blob/v2.2.6/PSReadLine/ReadLine.cs#L819. --- Closes #597
Prerequisites
Steps to reproduce
$PROFILE
following https://learn.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory#powershell-powershellexe-or-pwshexe:'
or a dot.
Expected behavior
PS> '
Actual behavior
PS>\'
Error details
No response
Environment data
Visuals
This is captured with Konsole 23.04.2 and tmux 3.3a. I can reproduce the same issue with PowerShell 7.3.4 on Windows 10 22H2.
The text was updated successfully, but these errors were encountered: