Prerequisites
Exception report
Summary
ANSI escape sequences returned by a custom prompt function cause character offset miscalculations during real-time syntax-error prompt recoloring, leaving an orphaned 'm' character or overwriting the prompt delimiter.
Screenshot
Environment data
PS Version: 7.6.5
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.4.5
PSReadLine EditMode: Windows
OS: 10.0.26100.1 (WinBuild.160101.0800)
BufferWidth: 120
BufferHeight: 30
Steps to reproduce
-
Start PowerShell with the following prompt function:
function prompt {
"`e[1;33mPS `e[1;34m$pwd`e[1;32m$('>' * ($nestedPromptLevel + 1)) `e[0m"
}
-
Type an opening quotation mark (" or ').
Expected behavior
The prompt delimiter (>) recolors cleanly to indicate an incomplete/syntax error state without visual artifacts.
Actual behavior
An orphaned m (from the trailing \e[0m SGR sequence) is printed at the end of the prompt or overwrites the > character.
Prerequisites
Exception report
N/ASummary
ANSI escape sequences returned by a custom
promptfunction cause character offset miscalculations during real-time syntax-error prompt recoloring, leaving an orphaned 'm' character or overwriting the prompt delimiter.Screenshot
Environment data
Steps to reproduce
Start PowerShell with the following
promptfunction:Type an opening quotation mark (" or ').
Expected behavior
The prompt delimiter (>) recolors cleanly to indicate an incomplete/syntax error state without visual artifacts.
Actual behavior
An orphaned m (from the trailing \e[0m SGR sequence) is printed at the end of the prompt or overwrites the > character.