-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Format selection #2272
Format selection #2272
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.
Yeah, this approach makes sense to me. Just some nitpicks in the comments.
Thanks for taking a look @dawedawe! |
Note for me: the restored trivia needs to be inside the selection. This will currently not be the case. |
d6e5ebb
to
7f0b384
Compare
Note to self: larger selections than the range of a node should not overlap with overlap other nodes. |
Extend visitLastChildNode.
…xact trimmed selection.
…th the FormatDocument.
Hello @dawedawe, this is a lot to review so I won't ask that you review every file. |
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.
Seems very well structured to me.
I hope people appreciate how much work you put into this feature.
Thanks for the review @dawedawe! I'm going to merge this one in, update the online tool and ask you to test this against your code base to detect any regressions. |
I'm trying to re-enable Format selection in Fantomas.
The old code used the tokenizer we won't don't expose anymore in Fantomas.FCS so I took a different approach.
The idea is to find an AST node (of a predefined selected set of types) and format it using an anonymous module. We exact the closest selected node and format from AST to get the result.
This isn't perfect but will work for 80 - 90% of the cases.
As a side remark, I'm strongly considering #2271 as well, but in a separate PR.
Initially thoughts @baronfel, @jindraivanek or @dawedawe?
TODO: