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

VS Code test-output terminal does not render styles #74

Closed
NiloCK opened this issue Mar 22, 2022 · 3 comments · Fixed by #189
Closed

VS Code test-output terminal does not render styles #74

NiloCK opened this issue Mar 22, 2022 · 3 comments · Fixed by #189
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@NiloCK
Copy link

NiloCK commented Mar 22, 2022

Like any reasonable person with a three-year-old, I'm making a TUI Connect-4 clone for local network play (toddlers cannot physically prevent you from making a blocking move when they are in another room).

Testing my work-in-progress had me seriously confused:

c4Colors

Turns out that the terminal which displays the output from this inline test-running button (maybe the entire integrated test runner) doesn't display any colours. (You would certainly know better than me how to characterize the behaviour).

Note that this is not the case for VSCode's more general terminal:

c4colorsWorking

Suggestions:

  • a word of caution in the readme
  • file (or fix) upstream (I did not check for existing upstream issues)

Nice library. Enjoying the renewed interest and vigor in modernizing cli / tui tooling. Good luck!

@meowgorithm
Copy link
Member

Thanks for the detailed report. We can definitely use some better docs around this.

The reason this happens is because Lip Gloss automatically degrades colors to the best available option in the given terminal. Because Go tests run in a sub-process, they're not attached to a TTY and thus Lip Gloss strips color output entirely.

However! You can force a color profile in your tests with SetColorProfile.

import (
    "github.com/charmbracelet/lipgloss"
    "github.com/muesli/termenv"
)

lipgloss.SetColorProfile(termenv.TrueColor)

P.S. This project looks really cool and we absolutely love it when people make games with our stuff. Please do let us know when it's available (twitter, fediverse, email, slack).

@bashbunni bashbunni added the question Further information is requested label Apr 8, 2022
@mfridman
Copy link

+1 on updating the docs. I had the opposite problem where everything worked fine locally (terminal and vs code), but when pushed to GitHub there was no color output in CI (GitHub Actions)

Adding an explicit color profile fixed the issue, although I suspect this may be an issue on my end.

CleanShot 2022-05-21 at 14 00 45@2x

CleanShot 2022-05-21 at 14 01 08@2x

@bashbunni bashbunni self-assigned this May 23, 2022
@bashbunni bashbunni added the documentation Improvements or additions to documentation label May 23, 2022
@bashbunni bashbunni linked a pull request May 24, 2022 that will close this issue
1 task
@till
Copy link

till commented Nov 22, 2022

Hey 👋🏼 — I think I am in a similar situation like @mfridman.

When I let lipgloss auto-detect the environment, then I have problems on GHA to use the tool in the steps. It stops and hangs — for as long as the workflow can run.

I changed the output of my tool to return json, which bypasses lipgloss and bubbletea entirely, then the steps complete within seconds. So it seems like detection to check for a TTY (or terminal) is needed.

I am not sure if this detection needs to be in lipgloss or bubbletea (or both).

I am currently trying this code to configure it:

	if fileInfo, _ := os.Stdout.Stat(); (fileInfo.Mode() & os.ModeCharDevice) != 0 {
		// we can be extra fancy since this is a terminal
	} else {
		// probably a non-interactive session in runner, pipe or CI tool
		lipgloss.SetColorProfile(termenv.Ascii)
	}

I guess at the very least, I hope SetColorProfile doesn't go away in future versions. :)

@bashbunni bashbunni removed their assignment Nov 24, 2022
@bashbunni bashbunni linked a pull request Mar 31, 2023 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
5 participants