diff --git a/src/ansi/ansi_writer.go b/src/ansi/ansi_writer.go
index 1311011e..e389a4cf 100644
--- a/src/ansi/ansi_writer.go
+++ b/src/ansi/ansi_writer.go
@@ -24,7 +24,8 @@ var (
{AnchorStart: ``, AnchorEnd: ``, Start: "\x1b[5m", End: "\x1b[25m"},
{AnchorStart: ``, AnchorEnd: ``, Start: "\x1b[7m", End: "\x1b[27m"},
}
- colorStyle = &style{AnchorStart: "COLOR", AnchorEnd: `>`, End: "\x1b[0m"}
+ resetStyle = &style{AnchorStart: "RESET", AnchorEnd: `>`, End: "\x1b[0m"}
+ backgroundStyle = &style{AnchorStart: "BACKGROUND", AnchorEnd: `>`, End: "\x1b[49m"}
)
type style struct {
@@ -335,7 +336,7 @@ func (w *Writer) Write(background, foreground, text string) {
w.hyperlinkState = OTHER
// reset colors
- w.writeEscapedAnsiString(colorStyle.End)
+ w.writeEscapedAnsiString(resetStyle.End)
// reset current
w.currentBackground = ""
@@ -410,9 +411,9 @@ func (w *Writer) writeSegmentColors() {
func (w *Writer) writeColorOverrides(match map[string]string, background string, i int) (position int) {
position = i
// check color reset first
- if match[ANCHOR] == colorStyle.AnchorEnd {
+ if match[ANCHOR] == resetStyle.AnchorEnd {
// make sure to reset the colors if needed
- position += len([]rune(colorStyle.AnchorEnd)) - 1
+ position += len([]rune(resetStyle.AnchorEnd)) - 1
// do not reset when colors are identical
if w.currentBackground == w.background && w.currentForeground == w.foreground {
@@ -429,7 +430,7 @@ func (w *Writer) writeColorOverrides(match map[string]string, background string,
}
if w.background.IsClear() {
- w.writeEscapedAnsiString(colorStyle.End)
+ w.writeEscapedAnsiString(backgroundStyle.End)
}
if w.currentBackground != w.background && !w.background.IsClear() {
diff --git a/src/ansi/ansi_writer_test.go b/src/ansi/ansi_writer_test.go
index ffa33dde..24011b6a 100644
--- a/src/ansi/ansi_writer_test.go
+++ b/src/ansi/ansi_writer_test.go
@@ -32,7 +32,7 @@ func TestWriteANSIColors(t *testing.T) {
{
Case: "Bold with color override",
Input: "<#ffffff>test>",
- Expected: "\x1b[1m\x1b[30m\x1b[38;2;255;255;255mtest\x1b[0m\x1b[30m\x1b[22m\x1b[0m",
+ Expected: "\x1b[1m\x1b[30m\x1b[38;2;255;255;255mtest\x1b[49m\x1b[30m\x1b[22m\x1b[0m",
Colors: &Colors{Foreground: "black", Background: ParentBackground},
},
{