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 #10891 - Formatting does not respect indentation within Razor comment blocks #10893

Merged
merged 2 commits into from
Sep 17, 2024

Conversation

tuespetre
Copy link
Contributor

@tuespetre tuespetre commented Sep 16, 2024

Altered HtmlFormattingPassBase to discard any TextChanges that start within a RazorCommentBlockSyntax and added a test to catch any regressions in the future.

Fixes #10891

@tuespetre tuespetre requested a review from a team as a code owner September 16, 2024 23:16
Copy link
Contributor

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

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

Thank you! <3


using var changesToKeep = new PooledArrayBuilder<TextChange>(capacity: changes.Length);

for (var i = 0; i < changes.Length; i++)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: A foreach loop is generally preferred, and it doesn't seem like i is doing anything important here.

<div>
@*
<div>
This comment's indentation will be preserved
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, or possibly paranoia, but just in case perhaps it would be good for the comment contents to not be indented perfectly. If we accidentally regress this in future, but also make @* indent its contents, this test may not fail. Even something as simple as this should do it:

Suggested change
This comment's indentation will be preserved
This comment's indentation will be preserved

Ugly, yes, but it's a test so it's okay :)

@tuespetre
Copy link
Contributor Author

Thanks @davidwengier. I see your community outreach on Reddit btw. That takes some guts, lol

I've made the requested changes, and also added a couple more small details to the test case for completeness

@phil-allen-msft phil-allen-msft merged commit a068170 into dotnet:main Sep 17, 2024
12 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Sep 17, 2024
@davidwengier
Copy link
Contributor

Thank you again for your contribution @tuespetre

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Formatting does not respect indentation within Razor comment blocks that are indented
3 participants