-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
Additional whitespace for LineCommentAfterSourceCode
when last character is a ,
#2589
Comments
fantomas/src/Fantomas.Core/Context.fs Lines 1065 to 1067 in 35f093c
Maybe there should be a different |
The bigger problem here is that the comment is assigned to the Theoretically speaking, we could allow the following to play out: let x
(
a: string // comment However, because of the comment, we can no longer put the comma on that same line let x
(
a: string // comment, `<- Leads to invalid F# code` There is a way to take this into account, but it would lead to the comment being on the next line: let x
(
a: string // comment
, b: string I'm not exactly sure how it would play out, so it could also be more like let x
(
a: string // comment
,
b: string Adding the commas to (*) The thing with comments after source code is that we don't write them directly but only once we move to the next line. This is to avoid exactly the invalid scenario as mentioned above. |
On a slightly more practical level, we could also check inside the fantomas/src/Fantomas.Core/Context.fs Line 87 in de8b5a7
Something like let currentLine =
let head = List.head m.Lines
if head.EndsWith(" ") && m.WriteBeforeNewline.StartsWith(" ") then
String.Concat(head, m.WriteBeforeNewline.TrimStart())
else
String.Concat(head, m.WriteBeforeNewline).TrimEnd() |
Issue created from fantomas-online
Code
Result
Problem description
When there is a
,
between source code and a comment the result prints an additional whitespace which doesn't get added if there is no,
.Extra information
Options
Fantomas main branch at 2022-10-14T16:59:37Z - 35f093c
Default Fantomas configuration
Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?
The text was updated successfully, but these errors were encountered: