Skip to content

stripSgrCodes leaves C1 SGR styling already supported by the ANSI parser #690

Description

@vishnujayvel

At main 3b602348afbbe082eb919b576b55926bbf8d19d6, stripSgrCodes removes ESC-prefixed SGR styling but leaves the C1 CSI form (\x9b) that the ANSI parser already supports.

Reproduction using the actual source module with the repository dependencies installed:

import { stripSgrCodes } from './src/utils/ansi.ts';

stripSgrCodes('\x9b31mred\x9b39m');
// Actual:   '\x9b31mred\x9b39m'
// Expected: 'red'

The existing C1 ANSI support was added in #660. The mismatch affects consumers of stripSgrCodes: foreground overrides can retain C1 foreground styling, and a truncated CustomCommand with preserveColors can miss its trailing reset.

A native reproduction against unchanged production source failed the equality assertion. Focused regressions also fail for C1-only and mixed ESC/C1 SGR removal and for the truncated CustomCommand reset. Ordinary ESC-prefixed SGR, unrelated CSI controls, and OSC sequences should retain their existing behavior.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions