Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix opa fmt location for non-key rules #4695

Merged

Commits on May 16, 2022

  1. Fix opa fmt location for non-key rules

    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>
    jaspervdj committed May 16, 2022
    Configuration menu
    Copy the full SHA
    3cc3e30 View commit details
    Browse the repository at this point in the history