Skip to content

Colorizing ContinuationPrompt causes cursor to be in wrong position #1188

@JustinGrote

Description

@JustinGrote

Environment data

PS version: 7.0.0-preview.5
PSReadline version: 2.0.0-beta6
os: 10.0.19018.1 (WinBuild.160101.0800)
PS file version: 7.0.0.0
HostName: Visual Studio Code Host
BufferWidth: 217
BufferHeight: 20

Happens in all hosts (windows terminal, etc.)

Steps to reproduce or exception report

I want my continuation prompt to match my promptText, but if I add the color, the prompt is off. I'd guess that PSReadline is not subtracting the ansi escape sequences from it's "how far to indent" count for continuationprompt.

It works fine, types fine, and if I take out the ansi color, indents fine however.

$plRight = "$([char]0xe0b4)"
$reset = "$([char]0x1b)[0m"
$grey = "$([char]0x1b)[90m"
$white = "$([char]0x1b)[1m"
$separator = "$grey$plRight$reset"

Set-PSReadLineOption -PromptText "$grey$plRight " -ContinuationPrompt "$plright$plright"

function prompt {
    "PS $($executionContext.SessionState.Path.CurrentLocation)$($separator * ($nestedPromptLevel + 1)) "
}

Capture

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions