Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colorized string doesn't get underlined correctly #233

Open
nobe4 opened this issue Jun 11, 2024 · 0 comments
Open

Colorized string doesn't get underlined correctly #233

nobe4 opened this issue Jun 11, 2024 · 0 comments

Comments

@nobe4
Copy link

nobe4 commented Jun 11, 2024

Consider the following code:

package main

import (
	"fmt"

	"github.com/fatih/color"
)

func main() {
	a := color.New(color.FgRed).SprintFunc()("aaa")
	b := color.New(color.FgBlue).SprintFunc()("bbb")
	c := color.New(color.Underline).SprintFunc()(a + b)
	fmt.Println(c)

	d := color.New(color.Underline).SprintFunc()("aaabbb")
	fmt.Println(d)
}

Image

I would expect the Underline to apply to the whole colorized string.

This is adapted of how I use it in

The issue seems to come from the usage of wrap in https://github.com/fatih/color/blob/main/color.go#L353-L357. It seems that unformat resets the entire format, not just the colors.

Is this expected?
If so, which approach would you recommend to make a colorized string fully underlined?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant