-
Notifications
You must be signed in to change notification settings - Fork 6
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
Feat/80 char line break #24
Conversation
@macintoshpie This PR solves the most problematic issues with long annotations. I have a few remarks enumerated below by order of priority. I would not use When considering the following formatting I wonder if we should not break lines only if the annotation exceeds 80 characters (with a margin, say 5-10 characters). The reason is that the model developer (or the development tool) may have organized properly the annotation, which the fomater will ruin, producing less readable code.
When formatting
Why is it treated differently than a standard declaration with line break after Another variant of that behavior, which in addition leads to a line exceeding 80 characters.
|
"=", | ||
",", | ||
"(", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tokens we allow line breaks on (when > max chars per line)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, seems like it would be easy to add others as needed!
@@ -18,6 +18,7 @@ import ( | |||
var ( | |||
write = flag.Bool("w", false, "overwrite the file(s)") | |||
versionFlag = flag.Bool("v", false, "display tool version") | |||
lineLength = flag.Int("line-length", -1, "how many characters allowed per line; -1 means no max") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new cli arg, defaults to no max line length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verrry noice
@AntoineGautier Thanks for the feedback, I removed the curly right brace as a possible char to break after. Unfortunately your other request to preserve original whitespace is not addressable currently @nllong let me know if you have any other thoughts or preferences on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks swell!
@@ -18,6 +18,7 @@ import ( | |||
var ( | |||
write = flag.Bool("w", false, "overwrite the file(s)") | |||
versionFlag = flag.Bool("v", false, "display tool version") | |||
lineLength = flag.Int("line-length", -1, "how many characters allowed per line; -1 means no max") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verrry noice
@macintoshpie You want to merge and bump release version? |
Background
Changes
, | = | (
The linebreak is "dumb" meaning that all it does is insert the newline and indentation. e.g. assume there's 80 chars before
c
An ideal implementation (in my opinion) would probably do something like this:
There are also some edgecases it can't handle. E.g. if we have
<insert 78 chars>=a.sub_component.y
it will not break after the=
, though we would probably expect that it would. We would like to considera.sub_component.y
a single "token"/"thing" but our current tokenizer does not currently (it considers them separate: "a", ".", "sub_component", ".", "y"). So it will write the "a", and by the time it wants to break (on the ".") we've passed our opportunity to break.