Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix opa fmt location for non-key rules (#4695)
Running the following through `opa fmt`: package foo bar { # before input.bar # after } Causes the `after` comment to be moved outside of the rule: package foo bar { # before input.bar } # after This was caused by `skipPast` in `closingLoc` being called even when there is no `[key]` part in the rule head. Adding a third clause fixed this; it seems like `closingLoc` is designed to take `0` in this case because of the `skipOpen > 0`. This did affect one other test case, where I had to add an extra newline to separate the comment from the rule head. Without that, `insertComments` (correctly, I guess) inserts: } # some special case Signed-off-by: Jasper Van der Jeugt <m@jaspervdj.be>
- Loading branch information
Showing
4 changed files
with
19 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package foo | ||
|
||
bar { | ||
# before | ||
input.bar | ||
# after | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package foo | ||
|
||
bar { | ||
# before | ||
input.bar | ||
# after | ||
} |
This file contains 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