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

Code action to offer to wrap Html attributes #11422

Merged
merged 2 commits into from
Feb 4, 2025

Conversation

davidwengier
Copy link
Contributor

Fixes #4296

@davidwengier davidwengier requested a review from a team as a code owner January 29, 2025 17:07
if (first)
{
firstAttributeLine = linePositionSpan.Start.Line;
sourceText.TryGetFirstNonWhitespaceOffset(attribute.Span, out var indentSizeOffset);
Copy link
Contributor

Choose a reason for hiding this comment

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

TryGetFirstNonWhitespaceOffset

Are there cases when attribute span starts with whitespace?

Copy link
Contributor Author

@davidwengier davidwengier Feb 4, 2025

Choose a reason for hiding this comment

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

Yes, the Razor syntax tree continues to be annoying, so (almost?) all of the attributes start with whitespace. The syntax nodes look a bit like[<][foo][ class="asdf"][/>].

{
firstAttributeLine = linePositionSpan.Start.Line;
sourceText.TryGetFirstNonWhitespaceOffset(attribute.Span, out var indentSizeOffset);
indentSize = linePositionSpan.Start.Character + indentSizeOffset;
Copy link
Contributor

Choose a reason for hiding this comment

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

indentSizeOffset

indentSizeOffset would be zero in most cases but not always?

Copy link
Contributor

@alexgav alexgav left a comment

Choose a reason for hiding this comment

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

:shipit:

@davidwengier davidwengier merged commit b16f63a into dotnet:main Feb 4, 2025
12 checks passed
@davidwengier davidwengier deleted the WrapAttributesCodeAction branch February 4, 2025 22:00
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Feb 4, 2025
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.

Refactoring or Code Style to wrap HTML attributes on multiple lines
2 participants