Skip to content
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

fix(fmt): preserve line comments in blocks #2197

Merged
merged 2 commits into from
Jul 4, 2022

Conversation

rkrasiuk
Copy link
Collaborator

@rkrasiuk rkrasiuk commented Jul 3, 2022

Motivation

on the block level, simple line comments get formatted as prefix comments

Example with old behavior

before formatting:

contract Format {
   constructor() {
       uint256 a = 1;

       // TODO: do this and that
   }
}

after first run:

contract Format {
   constructor() {
       uint256 a = 1;

       // TODO: do this and that
   }
}

after second run:

contract Format {
   constructor() {
       uint256 a = 1; // TODO: do this and that
   }
}

Solution

preserve the line comments on the block level

@rkrasiuk rkrasiuk marked this pull request as draft July 3, 2022 07:26
@rkrasiuk rkrasiuk marked this pull request as ready for review July 3, 2022 07:43
@rkrasiuk rkrasiuk requested review from mattsse and gakonst July 3, 2022 07:43
@rkrasiuk rkrasiuk added L-ignore Log: ignore PR in changelog Cmd-forge-fmt Command: forge fmt T-bug Type: bug labels Jul 3, 2022
@onbjerg onbjerg removed the L-ignore Log: ignore PR in changelog label Jul 3, 2022
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

clippy lints fixed on master

@gakonst gakonst merged commit 528f080 into master Jul 4, 2022
@gakonst gakonst deleted the rkrasiuk/fix-simple-line-comments branch July 4, 2022 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cmd-forge-fmt Command: forge fmt T-bug Type: bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants