Open garjust opened 1 year ago
Unless, I'm confused this isn't a feature of golines at all. golines (sometimes) shortens lines, but it doesn't ever lengthen them. (I also don't think that golines keeps track of its changes the way you have in mind. That is, if you run golines after you refactor, there's no saved state from a previous run. So it can't say "I shortened these lines because they were over my limit, but now I can fit them on one line, so I'll lengthen them instead.")
Sorry I did not mean in the sense that the tool has some knowledge of a previous run.
What I tried to mean is I expected the tool to encounter things like:
func(
a int,
) string {
...
}
and shorten it to:
func(a int) string {
...
}
Sorry I did not mean in the sense that the tool has some knowledge of a previous run.
What I tried to mean is I expected the tool to encounter things like:
func( a int, ) string { ... }
and shorten it to:
func(a int) string { ... }
Ah, got it. When you say "and shorten it," I guess you are thinking that the number of lines is shorter. Unfortunately, I don't think that golines checks for lines that are shorter than they might be while still fitting into the maximum line-length. In other words, I don't think that golines attempts to combine several short lines into a single longer (but not overly long!) line. Take a look at the blog post about the library for more discussion of what golines tries to do.
I'm also interested in this functionality. Considering golines
is now the de facto line-length formatter, would you please be up for adding this functionality into the project? Would a PR be merged? @telemachus
To clarify, I am not the maintainer, just a contributor. My point being, I can't say whether a PR might be merged. I'll ping @yolken who is the creator and (I believe) primary maintainer.
I noticed that after the tool multilines some code if that code is refactored such that it would now fit within the line length limit on a single line it does not get formatted back to a single line. Am I encountering a bug or is this intentionally not a feature / just not implemented?