Skip to content

Complete function completes common ANSI escape sequence in completion items #5044

Open

Description

@8LWXpg

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

From carapace-sh/carapace#997 (comment)

PSReadLine's Complete logic attempts to auto-complete the input with the "common prefix" of all available matches on the first <TAB>. While the actual CompletionText differ, Carapace prepends the same ANSI escape codes to the ListItemText of every entry to ensure styling. The Complete function correctly identifies this ANSI sequence as the shared prefix and prints it to the prompt.

Screenshot

Image

Environment data

PS Version: 7.5.4
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.4.5
PSReadLine EditMode: Windows
OS: 10.0.26100.7306 (WinBuild.160101.0800)
BufferWidth: 158
BufferHeight: 25

Steps to reproduce

Set-PSReadLineKeyHandler -Chord Tab -Function Complete
Register-ArgumentCompleter -Native -ScriptBlock {
    param($wordToComplete, $commandAst, $cursorPosition)
    @(
        [System.Management.Automation.CompletionResult]::new("aa", "`e[2maa", [System.Management.Automation.CompletionResultType]::ParameterValue, "1"),
        [System.Management.Automation.CompletionResult]::new("bb", "`e[2mbb", [System.Management.Automation.CompletionResultType]::ParameterValue, "2")
    )
} -CommandName 'bash'

Expected behavior

Completion should not include ANSI escape sequence

Actual behavior

Escape sequence is completed as part of the arguments

bash ^[[2m

Activity

  1. added
    Needs-Triage 🔍
    on Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-Triage 🔍

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions