Fix toFormat grouping by secondaryGroupSize when groupSize is 0 - #411
Open
chatman-media wants to merge 1 commit into
Open
Fix toFormat grouping by secondaryGroupSize when groupSize is 0#411chatman-media wants to merge 1 commit into
chatman-media wants to merge 1 commit into
Conversation
groupSize: 0 is supposed to turn grouping off entirely (per MikeMcl#407), but if secondaryGroupSize was also set the two get swapped internally and the check that's meant to disable grouping ends up looking at the secondary value instead. So e.g. { groupSize: 0, secondaryGroupSize: 2 } still grouped '123456789' into '1,23,45,67,89' instead of leaving it alone. Added tests covering this alongside the existing MikeMcl#407 cases.
Owner
|
Well, nowhere is it stated that "groupSize: 0 is supposed to disable grouping entirely", so this is not a "fix" but a suggestion to alter the current behaviour, which is how this PR should have been framed. The behaviour has always been that Having said that, it may be a worthwhile change and I will look at it closely presently. |
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.
groupSize: 0 is supposed to disable grouping entirely (this was just fixed for the plain case in #407), but it doesn't work if
secondaryGroupSizeis also set. The two values get swapped internally for the Indian-style grouping logic, and thegroupSize > 0check that's meant to short-circuit grouping ends up looking at the secondary value instead.Fixed by only doing the swap when the primary groupSize is actually greater than 0. Added tests next to the existing #407 cases, covering this combination.