Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@samcoe
Copy link
Contributor

@samcoe samcoe commented Sep 23, 2020

This PR fixes the bug where determining the terminal background color for markdown rendering was causing a weird interaction with PAGER. Now we will resolve the terminal background color before starting PAGER. Resolving the terminal background is a no-op if we are not outputting to TTY, the pager has already be started, or the GLAMOUR_STYLE environment variable is set to something other than auto.

closes #1822
cc #1930

@samcoe samcoe self-assigned this Sep 23, 2020
@samcoe samcoe force-pushed the fix-pager-glamour-bug branch 2 times, most recently from 1db9152 to 383a903 Compare September 24, 2020 10:56
@samcoe samcoe force-pushed the fix-pager-glamour-bug branch from 383a903 to ed40755 Compare September 24, 2020 11:06
@samcoe samcoe marked this pull request as ready for review September 24, 2020 11:13
@samcoe samcoe requested a review from a team September 24, 2020 12:35
Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! I only have style suggestions

func (s *IOStreams) ResolveBgColor() string {
style := os.Getenv("GLAMOUR_STYLE")
if (!s.ColorEnabled()) ||
(style != "" && style != "auto") ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looks like there are now two separate packages that independently look up GLAMOUR_STYLE and compare it to "auto". Could this be consolidated?

Copy link
Contributor Author

@samcoe samcoe Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree. This was my biggest issue with this approach. If GLAMOUR_STYLE is set we don't want to actually detect the terminal background color because we are not going to use those results, but right now we are throwing away what the GLAMOUR_STYLE is set to. I thought about setting BgColor to be GLAMOUR_STYLE which would save use from having to do it in the markdown package but then the naming felt wrong since it is not actually the BgColor. Which is how I ended up doing the check twice. I am happy to move in the direction I outlined above, or if there are better ideas I am open to hearing them.

@samcoe samcoe force-pushed the fix-pager-glamour-bug branch from 11ef875 to f0d4fbf Compare September 24, 2020 17:27
@samcoe samcoe force-pushed the fix-pager-glamour-bug branch from 4e06ede to 8f27cb3 Compare September 25, 2020 06:50
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

Successfully merging this pull request may close these issues.

gh repo view not scrolling in vscode integrated terminal

3 participants