-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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: fix formatter adding --
to multiple use
statements
#773
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.
Could you add a test that shows the behavior is fixed?
Inadvertently stashed my test… For the rename, it's because of a weird formatter bug, I'm going to explicit it |
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.
This should be solved where the problem is (in handling of the UseStatement),
this current approach could even cause a bug if there are two lines that are the same, it would filter them as well.
Plus not sure why renaming that struct in a test is needed or connected to any of this?
Suggested solution:
in traverse_ast_node()
where UseStatement is handled
if next_line
of code is a UseStatement,
and if there already exists in changes
the last_item.start
that equals to next_line.start
,
then they are the same UseStatement - so no need to handle it again, just ignore it.
* the renaming of the example struct `Lighthouse` and `Dart` is to have two different blocks of code. Otherwise the two code blocks are exactly identical (incl. comment) and the formatter adds an extra newline.
Ok, implementing the suggested solution. It turns out that the "struct" renaming was indeed linked to 2 blocks of code being identical and a newline appearing because of it. |
What were the odds lol |
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.
LGTM but left a question
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.
👍
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.
utACK
fe5016c
I updated the "Temporary workaround" section about formatting, because, as shown by fe5016c, we actually do format non-compiling code. |
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.
LGTM! Thanks for adding more test cases.
This PR fixes #684