Fix FORCE_COLOR to set exact level instead of minimum#672
Closed
veeceey wants to merge 1 commit intochalk:mainfrom
Closed
Fix FORCE_COLOR to set exact level instead of minimum#672veeceey wants to merge 1 commit intochalk:mainfrom
veeceey wants to merge 1 commit intochalk:mainfrom
Conversation
Previously, FORCE_COLOR was used as a floor value and terminal detection could return a higher level. For example, FORCE_COLOR=1 on a truecolor terminal would still give level 3. Now when FORCE_COLOR is set to a specific level (1, 2, or 3), that exact level is returned without further terminal capability checks. Fixes chalk#624
Member
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
When
FORCE_COLORis set to a specific level like1or2, the expected behavior is that the color support level is forced to exactly that value. However,FORCE_COLORwas being used as a floor/minimum value in_supportsColor, meaning terminal capability detection could still return a higher level.For example, on a terminal with
COLORTERM=truecolor, settingFORCE_COLOR=1would still give level 3 because the truecolor check fires after the minimum is set.The fix makes
_supportsColorreturn the forced level directly whenFORCE_COLORis explicitly set, skipping the terminal detection logic entirely. This matches the expected semantics — "force" means force to this exact level, not "ensure at least this level."Before:
After:
Fixes #624