Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Fix(pager): Resolve background color before staring pager #650

Merged
merged 1 commit into from
Mar 11, 2021

Conversation

zemzale
Copy link
Collaborator

@zemzale zemzale commented Mar 11, 2021

Description
So far we have started the pager and then got background color glamour
style from enviorment.

If enviorment value is not set it defaults to auto. Which in turn uses
termenv to resolve background color using some terminal escape code
sequences. The problem with this is that doing this when a pager like
less is running, just doesn't work and leaves less in a broken state.

To fix this we are now checking the background color manually and before
we start the pager.

Related Issue

Resolves #636

How Has This Been Tested?
Fixes hangs for less on my machine.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation
  • Chore (Related to CI or Packaging to platforms)

@profclems
Copy link
Owner

@zemzale kindly rebase the branch

@zemzale zemzale marked this pull request as draft March 11, 2021 08:28
@zemzale
Copy link
Collaborator Author

zemzale commented Mar 11, 2021

@profclems Will do. There seem to be some issues about this with tests anyways. So gotta fix that first

@codecov
Copy link

codecov bot commented Mar 11, 2021

Codecov Report

Merging #650 (be467fa) into trunk (b5e2eb6) will decrease coverage by 0.12%.
The diff coverage is 32.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##            trunk     #650      +/-   ##
==========================================
- Coverage   60.18%   60.05%   -0.13%     
==========================================
  Files          90       90              
  Lines        6414     6431      +17     
==========================================
+ Hits         3860     3862       +2     
- Misses       2191     2206      +15     
  Partials      363      363              
Impacted Files Coverage Δ
pkg/iostreams/iostreams.go 39.36% <0.00%> (-7.48%) ⬇️
pkg/utils/utils.go 43.33% <0.00%> (ø)
commands/issue/view/issue_view.go 85.82% <100.00%> (+0.11%) ⬆️
commands/mr/view/mr_view.go 75.52% <100.00%> (+0.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b5e2eb6...be467fa. Read the comment docs.

@zemzale zemzale marked this pull request as ready for review March 11, 2021 09:13
@zemzale zemzale requested a review from profclems March 11, 2021 09:13
@zemzale
Copy link
Collaborator Author

zemzale commented Mar 11, 2021

Rebased and tests working

Copy link
Owner

@profclems profclems left a comment

Choose a reason for hiding this comment

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

Thanks for working on this.

I have added a few suggestions in the inline review comments: we allow users set the glamour_style in the config so we should consider that.
So in the mr_view and issue_view, we get the glamour_style from the config and pass to the ResolveBackgroundColor(style string).

Comment on lines 172 to 173
func (s *IOStreams) ResolveBackgroundColor() string {
style := os.Getenv("GLAMOUR_STYLE")
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
func (s *IOStreams) ResolveBackgroundColor() string {
style := os.Getenv("GLAMOUR_STYLE")
func (s *IOStreams) ResolveBackgroundColor(style string) string {
if(style == "") {
style = os.Getenv("GLAMOUR_STYLE")
}

@@ -93,6 +93,7 @@ func NewCmdView(f *cmdutils.Factory) *cobra.Command {
}
}

f.IO.ResolveBackgroundColor()
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
f.IO.ResolveBackgroundColor()
f.IO.ResolveBackgroundColor(opts.GlamourStyle)

@@ -77,6 +77,7 @@ func NewCmdView(f *cmdutils.Factory) *cobra.Command {
}
}

f.IO.ResolveBackgroundColor()
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
f.IO.ResolveBackgroundColor()
f.IO.ResolveBackgroundColor(glamourStyle)

So far we have started the pager and then got background color glamour
style from enviorment.

If enviorment value is not set it defaults to auto. Which in turn uses
termenv to resolve background color using some terminal escape code
sequences. The problem with this is that doing this when a pager like
less is running, just doesn't work and leaves less in a broken state.

To fix this we are now checking the background color manually and before
we start the pager.

Issue profclems#636
@zemzale
Copy link
Collaborator Author

zemzale commented Mar 11, 2021

Fixed the issue with not config-defined styles.

I also removed the GlamourStyle variables being passed around since we really don't need that anymore, because we are resolving the style before, and it's available from IOStreams.

Copy link
Owner

@profclems profclems left a comment

Choose a reason for hiding this comment

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

LGTM

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

Successfully merging this pull request may close these issues.

Unexpected behaviour using issue view on Ubuntu, Zsh
2 participants