scalameta / scalafmt

Code formatter for Scala
http://scalameta.org/scalafmt
Apache License 2.0
1.44k stars 277 forks source link

Two spaces after a full stop. #4146

Closed Y-Less closed 3 months ago

Y-Less commented 3 months ago

There should be a way to configure the number of spaces put after a full stop in comments.

Configuration (required)

Please paste the smallest possible set of .scalafmt.conf configuration parameters that reproduces the problem:

version = 3.8.3
runner.dialect = scala3
#docstrings.spacesAfterFullStop = 2

Command-line parameters (required)

When I run scalafmt via CLI like this: scalafmt-native

Steps

Given code like this:

/**
 * Hello.  This is a comment.  With two spaces after the full stops.
 */

Problem

Scalafmt formats code like this:

/** Hello. This is a comment. With two spaces after the full stops.
  */

Expectation

I would like the formatted output to look like this:

/** Hello.  This is a comment.  With two spaces after the full stops.
  */

Workaround

You can disable the formatting on the line, but I do like the mutli-line reflow ability for comments.

Notes

https://www.independent.co.uk/tech/one-space-or-two-spaces-after-a-full-stop-scientists-have-finally-found-the-answer-a8337646.html

Ignore the tag line, the conclusion is that two spaces are better, at least in fixed-width fonts as most code is.

You can have my double space when you pry it from my cold, dead hands

Megan McArdle, via the linked article.

kitbellew commented 3 months ago

with all due respect, this is a code formatting tool. comments are designed to be interpreted by scaladoc generation tools.

personal suggestion: if you write multiple complex sentences in a comment, separate them into paragraphs. code comment is not a treatise, after all.

Y-Less commented 2 months ago

Except this tool already does touch and modify comments. If it completely ignored them that would be a reasonable solution, but it is removing the extra spaces so it already is doing this formatting in some way.