Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Reflow long comment lines which don't end with a period#59

Open
shivansh wants to merge 4 commits into
segmentio:masterfrom
shivansh:shivansh/comment-reflow
Open

Reflow long comment lines which don't end with a period#59
shivansh wants to merge 4 commits into
segmentio:masterfrom
shivansh:shivansh/comment-reflow

Conversation

@shivansh

@shivansh shivansh commented Mar 19, 2022

Copy link
Copy Markdown
Contributor
$ cat x.go
package main

// Unlike the above comment block, only the current line in this comment block has length greater than the
// target maximum line length
// but since the previous line doesn't end with a period, it should be reflown with this line
// despite both the lines being shorter than the target maximum line length.

$ golines --shorten-comments x.go
package main

// Unlike the above comment block, only the current line in this comment block has length greater
// than the
// target maximum line length
// but since the previous line doesn't end with a period, it should be reflown with this line
// despite both the lines being shorter than the target maximum line length.

The modified behavior is to reflow long comment lines which don't end
with a period with the consecutive comment lines, irrespective of the
latter being long or not.

$ golines --shorten-comments x.go
package main

// Unlike the above comment block, only the current line in this comment block has length greater
// than the target maximum line length but since the previous line doesn't end with a period, it
// should be reflown with this line despite both the lines being shorter than the target maximum
// line length.

@shivansh shivansh changed the title Reflow long lines which don't end with period Reflow long lines which don't end with a period Mar 19, 2022
@shivansh
shivansh force-pushed the shivansh/comment-reflow branch from c4a54ae to fc397bd Compare March 19, 2022 08:48
@shivansh

Copy link
Copy Markdown
Contributor Author

Though the comment formatting is still in an experimental stage, I believe this PR will improve it to some extent. However, if this is accepted, a note should be added in README for users to be aware of the usage of period (.) to avoid unexpected behavior.
For example -

$ cat x.go 
package main

// - this is a long comment this is a long comment this is a long comment this is a long comment this is a long comment.
// - this is a short comment

$ golines --shorten-comments x.go
package main

// - this is a long comment this is a long comment this is a long comment this is a long comment
// this is a long comment - this is a short comment

The above unexpected behavior can be avoided by adding a . at the end of first bullet:

$ cat x.go 
package main

// - this is a long comment this is a long comment this is a long comment this is a long comment this is a long comment.
// - this is a short comment

$ golines --shorten-comments x.go
package main

// - this is a long comment this is a long comment this is a long comment this is a long comment
// this is a long comment.
// - this is a short comment

@shivansh shivansh changed the title Reflow long lines which don't end with a period Reflow long comment lines which don't end with a period Mar 19, 2022
	$ cat x.go
	package main

	// Unlike the above comment block, only the current line in this comment block has length greater than the
	// target maximum line length
	// but since the previous line doesn't end with a period, it should be reflown with this line
	// despite both the lines being shorter than the target maximum line length.

	$ golines --shorten-comments x.go
	package main

	// Unlike the above comment block, only the current line in this comment block has length greater
	// than the
	// target maximum line length
	// but since the previous line doesn't end with a period, it should be reflown with this line
	// despite both the lines being shorter than the target maximum line length.

The modified behavior is to reflow long comment lines which don't end
with a period with the consecutive comment lines, irrespective of the
latter being long or not.

	$ golines --shorten-comments x.go
	package main

	// Unlike the above comment block, only the current line in this comment block has length greater
	// than the target maximum line length but since the previous line doesn't end with a period, it
	// should be reflown with this line despite both the lines being shorter than the target maximum
	// line length.
@shivansh
shivansh force-pushed the shivansh/comment-reflow branch from fc397bd to d922ed2 Compare March 19, 2022 09:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant