You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SetWriter and UnsetWriter on Color are not symmetric when it comes to the autodetection of support: this has created an issue that was difficult to understand in code i have been working on.
Namely, SetWriter delegates the autodetection to isNoColorSet(), while UnsetWriter() does the same, but checks again the global NoColo flag (which is also consulted in isNoColorSet()). The consequence is that when global autodetected NoColor is set, but Color has been forced to not-NoColor (sorry for the double negation), escape sequences are opened, but never closed.
This looks like a minor oversight. See below the proposed change, maybe a bit small to deserve a pull request.
SetWriter and UnsetWriter on Color are not symmetric when it comes to the autodetection of support: this has created an issue that was difficult to understand in code i have been working on.
Namely, SetWriter delegates the autodetection to isNoColorSet(), while UnsetWriter() does the same, but checks again the global NoColo flag (which is also consulted in isNoColorSet()). The consequence is that when global autodetected NoColor is set, but Color has been forced to not-NoColor (sorry for the double negation), escape sequences are opened, but never closed.
This looks like a minor oversight. See below the proposed change, maybe a bit small to deserve a pull request.
diff --git a/color.go b/color.go
index 81094e8..d79a24c 100644
--- a/color.go
+++ b/color.go
@@ -205,10 +205,6 @@ func (c *Color) UnsetWriter(w io.Writer) {
return
}
- if NoColor {
- return
- }
-
fmt.Fprintf(w, "%s[%dm", escape, Reset)
}
The text was updated successfully, but these errors were encountered: