Skip to content

Code action to offer to wrap Html attributes#11422

Merged
davidwengier merged 2 commits intodotnet:mainfrom
davidwengier:WrapAttributesCodeAction
Feb 4, 2025
Merged

Code action to offer to wrap Html attributes#11422
davidwengier merged 2 commits intodotnet:mainfrom
davidwengier:WrapAttributesCodeAction

Conversation

@davidwengier
Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
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
Copy Markdown
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
Copy link
Copy Markdown
Member Author

FYI @leslierichardson95 for a new code action for Razor coming in a future 17.14 preview

@jjonescz jjonescz modified the milestones: Next, 17.14 P2 Mar 11, 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

3 participants