fix: Calculate the initial indent correctly in a couple edge cases.#45
Merged
fix: Calculate the initial indent correctly in a couple edge cases.#45
Conversation
1. When the first seen line is one of the `group_prefixes`.
2. When the first seen line is another keep-sorted directive.
Idempotency output before this change:
```
$ go test ./...
? github.com/google/keep-sorted [no test files]
? github.com/google/keep-sorted/cmd [no test files]
--- FAIL: TestGoldens (0.66s)
--- FAIL: TestGoldens/group (0.00s)
--- FAIL: TestGoldens/group/group (0.66s)
golden_test.go:105: keep-sorted diff on keep-sorted output (should be idempotent) (-want +got)
(
"""
... // 180 identical lines
case 5:
// keep-sorted-test end
- return 10
case 2:
- return 2;
case 4:
+ case 6:
+ return 10
+ return 2;
return 4;
- case 6:
return 6;
// keep-sorted-test end
"""
)
FAIL
FAIL github.com/google/keep-sorted/goldens 0.686s
ok github.com/google/keep-sorted/keepsorted (cached)
FAIL
```
Also, check the git history to see how group.out evolved.
KatrinaHoffert
approved these changes
Oct 23, 2024
Member
KatrinaHoffert
left a comment
There was a problem hiding this comment.
Good idea, that idempotency check.
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.
group_prefixes.Idempotency output before this change:
Also, check the git history to see how group.out evolved.