docs: fix GetTabWidth comment on the unset return value#706
Open
sueun-dev wants to merge 1 commit into
Open
Conversation
GetTabWidth's comment said an unset tab width returns 4, but the getter returns getAsInt(tabWidthKey), which is 0 when no width has been set. The implicit default of 4 is applied at render time in maybeConvertTabs, not by the getter; TestStyleUnset already asserts GetTabWidth() != 4 after Unset.
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.
The doc comment on
GetTabWidthsays an unset tab width returns 4:It returns 0, not 4. The getter is
return s.getAsInt(tabWidthKey), andgetAsIntreturns 0 for an unset key, soNewStyle().GetTabWidth()is 0. The default of 4 is applied later, inmaybeConvertTabsat render time, not by the getter.TestStyleUnsetalready assertsGetTabWidth() != 4afterUnsetTabWidth, so the current return value is intended and the comment is the part that's wrong.This corrects the comment to match the behavior: the getter returns the configured value (0 when unset), and tabs still expand to 4 spaces at render time when no width is set.
gofmt,go vet,go build, andgo test ./...are clean.