Fix invalid ANSI SGR escape code in JSON and diff colorization
Replace `1;38` with `1;37` (bold white) in the delimiter/header color constant. SGR parameter 38 is the extended foreground color prefix and requires sub-parameters (e.g. `38;5;n` or `38;2;r;g;b`), so using it bare produces an invalid escape sequence. Most terminals silently ignore the malformed parameter, masking the bug. Fixes cli/cli#12683 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
3521604ed2
commit
48951aca01
4 changed files with 9 additions and 9 deletions
|
|
@ -190,7 +190,7 @@ func fetchDiff(httpClient *http.Client, baseRepo ghrepo.Interface, prNumber int,
|
|||
const lineBufferSize = 4096
|
||||
|
||||
var (
|
||||
colorHeader = []byte("\x1b[1;38m")
|
||||
colorHeader = []byte("\x1b[1;37m")
|
||||
colorAddition = []byte("\x1b[32m")
|
||||
colorRemoval = []byte("\x1b[31m")
|
||||
colorReset = []byte("\x1b[m")
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ func Test_diffRun(t *testing.T) {
|
|||
Patch: false,
|
||||
},
|
||||
wantFields: []string{"number"},
|
||||
wantStdout: fmt.Sprintf(testDiff, "\x1b[m", "\x1b[1;38m", "\x1b[32m", "\x1b[31m"),
|
||||
wantStdout: fmt.Sprintf(testDiff, "\x1b[m", "\x1b[1;37m", "\x1b[32m", "\x1b[31m"),
|
||||
httpStubs: func(reg *httpmock.Registry) {
|
||||
stubDiffRequest(reg, "application/vnd.github.v3.diff", fmt.Sprintf(testDiff, "", "", "", ""))
|
||||
},
|
||||
|
|
@ -313,7 +313,7 @@ func Test_colorDiffLines(t *testing.T) {
|
|||
"%[4]s+foo%[2]s\n%[5]s-b%[1]sr%[2]s\n%[3]s+++ baz%[2]s\n",
|
||||
strings.Repeat("a", 2*lineBufferSize),
|
||||
"\x1b[m",
|
||||
"\x1b[1;38m",
|
||||
"\x1b[1;37m",
|
||||
"\x1b[32m",
|
||||
"\x1b[31m",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
colorDelim = "1;38" // bright white
|
||||
colorDelim = "1;37" // bold white
|
||||
colorKey = "1;34" // bright blue
|
||||
colorNull = "36" // cyan
|
||||
colorString = "32" // green
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func TestWrite(t *testing.T) {
|
|||
r: bytes.NewBufferString(`{}`),
|
||||
indent: "",
|
||||
},
|
||||
wantW: "\x1b[1;38m{\x1b[m\x1b[1;38m}\x1b[m\n",
|
||||
wantW: "\x1b[1;37m{\x1b[m\x1b[1;37m}\x1b[m\n",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
|
|
@ -43,9 +43,9 @@ func TestWrite(t *testing.T) {
|
|||
r: bytes.NewBufferString(`{"hash":{"a":1,"b":2},"array":[3,4]}`),
|
||||
indent: "\t",
|
||||
},
|
||||
wantW: "\x1b[1;38m{\x1b[m\n\t\x1b[1;34m\"hash\"\x1b[m\x1b[1;38m:\x1b[m " +
|
||||
"\x1b[1;38m{\x1b[m\n\t\t\x1b[1;34m\"a\"\x1b[m\x1b[1;38m:\x1b[m 1\x1b[1;38m,\x1b[m\n\t\t\x1b[1;34m\"b\"\x1b[m\x1b[1;38m:\x1b[m 2\n\t\x1b[1;38m}\x1b[m\x1b[1;38m,\x1b[m" +
|
||||
"\n\t\x1b[1;34m\"array\"\x1b[m\x1b[1;38m:\x1b[m \x1b[1;38m[\x1b[m\n\t\t3\x1b[1;38m,\x1b[m\n\t\t4\n\t\x1b[1;38m]\x1b[m\n\x1b[1;38m}\x1b[m\n",
|
||||
wantW: "\x1b[1;37m{\x1b[m\n\t\x1b[1;34m\"hash\"\x1b[m\x1b[1;37m:\x1b[m " +
|
||||
"\x1b[1;37m{\x1b[m\n\t\t\x1b[1;34m\"a\"\x1b[m\x1b[1;37m:\x1b[m 1\x1b[1;37m,\x1b[m\n\t\t\x1b[1;34m\"b\"\x1b[m\x1b[1;37m:\x1b[m 2\n\t\x1b[1;37m}\x1b[m\x1b[1;37m,\x1b[m" +
|
||||
"\n\t\x1b[1;34m\"array\"\x1b[m\x1b[1;37m:\x1b[m \x1b[1;37m[\x1b[m\n\t\t3\x1b[1;37m,\x1b[m\n\t\t4\n\t\x1b[1;37m]\x1b[m\n\x1b[1;37m}\x1b[m\n",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
|
|
@ -63,7 +63,7 @@ func TestWrite(t *testing.T) {
|
|||
r: bytes.NewBufferString(`{{`),
|
||||
indent: "",
|
||||
},
|
||||
wantW: "\x1b[1;38m{\x1b[m\n",
|
||||
wantW: "\x1b[1;37m{\x1b[m\n",
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue