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

Can gradle tidy reflow text properly when it inserts newlines? #13766

Open
mikemccand opened this issue Sep 11, 2024 · 4 comments
Open

Can gradle tidy reflow text properly when it inserts newlines? #13766

mikemccand opened this issue Sep 11, 2024 · 4 comments

Comments

@mikemccand
Copy link
Member

Description

I'm working on #13519, and ran gradle tidy to ... tidy things up, and it does this:

  // verifies it's fine to change your mind on the number of bits quantization you want for the same                                                                                                                    
  // field                                                                                                                                                                                                              
  // in the same index by changing up the Codec.  This is allowed because at merge time we                                                                                                                              
  // requantize the                                                                                                                                                                                                     
  // vectors.                                                                                                                                                                                                           

It's because my original line wrap was too long for its taste, which is fine. But, then it creates these widow lines with just one or two words. I can revisit and reflow to right column width, manually, but can we fix tidy to not do this? It would ideally not gleefully create widow lines like this!

@gsmiller
Copy link
Contributor

+1, I'd love to have this improvement!

@dweiss
Copy link
Contributor

dweiss commented Sep 11, 2024

I don't think you can fix this, no. Use block comments - they are formatted properly: /*... */

@dweiss
Copy link
Contributor

dweiss commented Sep 11, 2024

For clarity: you can, of course, try to file a feature request to google java format, but I think it works as advertised - you're using line comments as a block comment... Reflowing these would mean intentional line comments would be lost.

// For example, I wouldn't want this:
// - to
// - be
// - concatenated.

@dweiss
Copy link
Contributor

dweiss commented Sep 12, 2024

So I just double checked and block-level comments are treated as preformatted within code. This:

    /*
     * fba sdifhopi hweifh swehf doish dsopih ewfpoih efwspoihb wepihb apin wef. spedfih [wefph wepfih wqefdpoi qp[hjfaph we.
     * bar bar
     */

    // fba sdifhopi hweifh swehf doish dsopih ewfpoih efwspoihb wepihb apin wef. spedfih [wefph wepfih wqefdpoi qp[hjfaph we.
    // bar bar

is tidied up to this:

    /*
     * fba sdifhopi hweifh swehf doish dsopih ewfpoih efwspoihb wepihb apin wef. spedfih [wefph wepfih wqefdpoi qp[hjfaph we.
     * bar bar
     */

    // fba sdifhopi hweifh swehf doish dsopih ewfpoih efwspoihb wepihb apin wef. spedfih [wefph
    // wepfih wqefdpoi qp[hjfaph we.
    // bar bar

I personally think this is the right choice by gjf - breaks long lines into visibility but does not break any other line comments (and potentially damage them). Block comments /* */ can be used to preserve any formatting that should not be touched at all.

I think this issue can be closed, sorry if it bothers you, but it's an operator's error. :)

There are more headaches coming with the markdown comments spec [1]. It'll be fun.

[1] https://openjdk.org/jeps/467

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

No branches or pull requests

3 participants