-
Notifications
You must be signed in to change notification settings - Fork 8
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
Make the formatter keep comments #17
Comments
I wonder if you can infer where comments are by using offsets? For instance, if you have this
Then this command reveals where the first part of code is, it starts at 19.
So, that means 0 - 19 may be comments.
Then we can see this section
Then we could do this
Kind of a long heuristic way to go, but it may be work-able? |
That is a different (and I believe better) algorithm. The algorithm I first thought is: After it found them, split in between. So you will have:
Split the sections in yes-code and no-code, (a much larger process than your logic) |
I saw your code, if it works I'm fine with yours too. I was just suggesting an alternative method. I think it would be much better if we could keep track of all comments during parsing so we're not guessing. |
In the current status,
nufmt
strips comments, wherever they are from the code.Because of parsing with
.parse()
I would be cool if once the
vec<u8>
is loaded, split the comments and format "sections of code" inbetween comments, so we can then collect all the comments-code together afterwards.Also, there is a test skipped with this very feature:
ignore_comments
The text was updated successfully, but these errors were encountered: