Skip to content

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

Merged
merged 4 commits into from
Jul 9, 2018

Conversation

uniqueiniquity
Copy link
Contributor

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.

@uniqueiniquity uniqueiniquity requested review from mhegazy and a user June 30, 2018 00:17
return undefined;
}

return createOutliningSpanFromBounds(node.getStart(), node.getEnd(), OutliningSpanKind.Code);
Copy link

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();
Copy link

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());
Copy link

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

@uniqueiniquity uniqueiniquity merged commit b5f5513 into microsoft:master Jul 9, 2018
@uniqueiniquity uniqueiniquity deleted the jsxFolding branch July 9, 2018 16:36
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.

2 participants