-
-
Notifications
You must be signed in to change notification settings - Fork 204
Fix idempotency issue with comment after type decl without equals, 3145 #3163
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
Conversation
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.
Pull Request Overview
This PR fixes an idempotency issue where a type declaration without an = but with a trailing comment would always emit an extra newline.
- Introduces a new formatter function that omits the newline in this specific case
- Updates
genTypeDefnto pick newline vs. no-newline behavior based on presence ofEqualsToken - Adds a targeted test and updates the changelog entry
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Fantomas.Core/Context.fsi | Added signature for sepSpaceOrIndentIfExpressionExceedsPageWidth |
| src/Fantomas.Core/Context.fs | Implemented new separator and wired it into expression logic |
| src/Fantomas.Core/CodePrinter.fs | Updated genTypeDefn to select between the two separator functions |
| src/Fantomas.Core.Tests/TypeDeclarationTests.fs | Added test for type decl without = and trailing comment |
| CHANGELOG.md | Documented the fix under Fixed |
Comments suppressed due to low confidence (2)
src/Fantomas.Core.Tests/TypeDeclarationTests.fs:3686
- Add a complementary test for a type alias with an
=and trailing comment to ensure the original newline logic (sepSpaceOrIndentAndNlnIfExpressionExceedsPageWidth) remains correct.
let ``type without body but with comment produces superfluous newline, 3145`` () =
src/Fantomas.Core/Context.fs:751
- [nitpick] Consider renaming this function to something like
sepSpaceOrIndentWithoutNlnIfExpressionExceedsPageWidthto more clearly indicate that it omits the newline behavior.
let sepSpaceOrIndentIfExpressionExceedsPageWidth expr (ctx: Context) =
…an equals" This reverts commit d558322.
…geWidth conditional in else branch via optSingle
nojaf
left a comment
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.
Great, thank you!
|
@dawedawe do we want to release a 7.0.2? |
I'll look into one or two more fixes in the next couple of days. Let's release after that. |
Fixes #3145
It's actually about type decls without an equals but a comment after.
See here
Ideally we could detect that in
expressionExceedsPageWidth(or even below that) as theinfo.ConfirmedMultilineis the root cause, but I don't see a good way to pass that down there.