-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Expose indentation suppressor from SmartIndenter #4757
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.
Use undefined, not null
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.
@DanielRosenwasser Fixed.
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.
undefined not null
|
Ping @vladima |
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.
to me condition SI.shouldInheritParentIndentation() ? 0 : delta look more clear and it is doing the same thing.
- if delta is not-null-or-zero then body of
getDeltaboils down toSI.shouldInheritParentIndentation() ? 0 : delta - if delta zero then
getDeltaevaluates to justdeltawhich will mean the same
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.
You're right, it's doing the same thing. I was to pass the SI check when delta value is already zero but I agree that it looks less clear. Do you want me to fix this?
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.
yes, please
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.
Done!
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.
remove parens around child
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.
Done!
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 marked as /@internal/
|
sorry for the delay. Can you add the @internal annotation in your next PR. |
Expose indentation suppressor from SmartIndenter
Separated from #4609.
shouldIndentChildNodefunction already have indentation suppressing feature, but currently auto-formatter disables it to get delta value and implements another suppressor incomputeIndentationfunction.This PR split the suppressor from
shouldIndentChildNodeand expose it as a separate function so that formatter can use it without implementing its own one.The function will help suppress indentation of:
ImportClausenode inImportDeclarationnode. (Fix named export/import formatting #4609)JsxClosingElementnode. (Fixing JSX/TSX closing tag/attribute/expression formatting #4398)Note:
shouldInheritParentIndentationand its internalnodeWillIndentChildreceives TextRangeWithKind to check more conditions other than syntax kind.