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

Associate comments on the same line as the closing curly brace with the statement #2

Open
Hubro opened this issue Jun 4, 2023 · 0 comments

Comments

@Hubro
Copy link
Owner

Hubro commented Jun 4, 2023

Comments on the same line as a closing curly brace should be associated with the statement, much like comments on the same line as a semi-colon is captured in post_comments.

For example:

type enumeration {
  enum foo { value 10; } // Comment associated with "foo"
  enum bar { value 20; } // Comment associated with "bar"
}

Currently the comments are treated as their own nodes, which leads to this formatting:

type enumeration {
  enum foo {
    value 10;
  }
  // Comment associated with "foo"
  enum bar {
    value 20;
  }
  // Comment associated with "bar"
}

Instead, these comments should be captured into post_comments as well, resulting in the following formatting:

type enumeration {
  enum foo { // Comment associated with "foo"
    value 10;
  }
  enum bar { // Comment associated with "bar"
    value 20;
  }
}

This means it's technically possible for the formatter to put two single-line comments on the same line, but that should never happen in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant