-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add outlining spans for JSX elements #25329
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
return undefined; | ||
} | ||
|
||
return createOutliningSpanFromBounds(node.getStart(), node.getEnd(), OutliningSpanKind.Code); |
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.
.getStart(sourceFile)
|
||
function spanForJSXElement(node: JsxElement): OutliningSpan | undefined { | ||
const textSpan = createTextSpanFromBounds(node.openingElement.getStart(), node.closingElement.getEnd()); | ||
const tagName = node.openingElement.tagName.getText(); |
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.
.getText(sourceFile)
} | ||
|
||
function spanForJSXElement(node: JsxElement): OutliningSpan | undefined { | ||
const textSpan = createTextSpanFromBounds(node.openingElement.getStart(), node.closingElement.getEnd()); |
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.
Nit: .getStart(sourceFile)
for better performance
Fixes #23273 .
This PR adds outlining regions for JSX elements in two ways:
For JSX elements (with an opening tag and a closing tag), we provide an outlining region that spans the whole element. This matches the behavior in Visual Studio for HTML files. When collapsed, the text
<tagname>…</tagname>
is shown, regardless of attributes.For JSX opening elements (including self-closing elements), we provide an outlining region that spans the attributes. This allows tags with multiple lines of attributes to be collapsed.