-
Notifications
You must be signed in to change notification settings - Fork 30k
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
tty: truecolor check moved before 256 check #30474
Closed
Closed
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9f3139c
tty: improve color check order highest spec first
duncanhealy 4cd885f
tty: add test for TERM and COLORTERM set
duncanhealy 7dde89e
tty: move COLORTERM check outside TERM closure
duncanhealy 7df205f
tty: remove extra if check for COLORTERM
duncanhealy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looks like this
if
statement can be removed,if (env.COLORTERM === 'truecolor' || env.COLORTERM === '24bit') { /* ... */ }
is sufficient.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @lpinca this is to catch the case when no TERM environment variable is set
without this COLORS_2 is returned which fails an existing test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get it, if
env.COLORTERM
is truthy,COLORS_16m
is returned only ifenv.COLORTERM === 'truecolor' || env.COLORTERM === '24bit'
otherwise nothing is done so why not using onlyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COLORTERM can be set to values other than
truecolor
and24bit
.yes
no
gnome-terminal
are other values used. We want to return the higest spec tty capability available first. If you remove the second check forenv.COLORTERM
you miss the case when TERM is not set but COLORTERM is nottruecolor
or24bit
. If you leave the code as it was before you get 256 color terminal when your terminal is capable of 16M. Basically we are moving the COLORS_256 check inbetween the COLORS_16m and the COLORS_16 checksThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW this is what I'm suggesting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is equal to
which is equal to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you remove the bottom if and
make test
you can see the case when it failsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've applied the patch in my previous comment and tests pass.
What you mean with bottom
if
? The one on line 197? If so I'm not suggesting to remove it. I never did. Anyway it does not matter, it is not very important :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok yes we can remove the nested if - I thought you were talking about the second
if (env.COLORTERM)
- I'll update the pull request now