Fix: Respect config file width values including width: 0#901
Open
gitpushoriginmaster wants to merge 1 commit intocharmbracelet:masterfrom
Open
Fix: Respect config file width values including width: 0#901gitpushoriginmaster wants to merge 1 commit intocharmbracelet:masterfrom
gitpushoriginmaster wants to merge 1 commit intocharmbracelet:masterfrom
Conversation
Add viper.IsSet("width") check to prevent auto-detection from
overriding explicit config file values. This allows width: 0
in glow.yml to disable word wrapping as documented.
Previously, the validateOptions function only checked if the
CLI flag was set, causing config file values to be ignored.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The
widthsetting inglow.ymlis being ignored. When users setwidth: 0to disable word wrapping, glow overrides it with auto-detected terminal width or defaults to 80. This forces users to pass-w 0on every command invocation.Current vs Expected Behavior
glow -w 0width: 0in glow.ymlwidth: 100in glow.ymlRoot Cause
The
validateOptions()function checks if the CLI flag was set, but not if the config file specified a value:This causes auto-detection to run and override explicit config file values.
Solution
Add one condition to skip auto-detection when config file sets width:
The
viper.IsSet("width")check returnstruewhen the key exists in the config file (even if set to0), allowing us to distinguish between "user set it to 0" vs "uninitialized default of 0".Why This Is Minimal
Single line change - only adds
&& !viper.IsSet("width")to existing condition.Preserves all functionality:
No breaking changes - users relying on auto-detection or CLI flags see no difference.
Correct Priority After Fix
Test Scenarios
glow -w 0 file.mdwidth: 0in configwidth: 150in config-w 50withwidth: 100in config