Skip to content

Fix crash in 'Wrap in JSX Fragment' quick fix #52816

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 2 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/services/formatting/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ function formatSpanWorker(
isFirstListItem?: boolean): number {
Debug.assert(!nodeIsSynthesized(child));

if (nodeIsMissing(child)) {
if (nodeIsMissing(child) || isGrammarError(parent, child)) {
return inheritedIndentation;
}

Expand Down Expand Up @@ -864,7 +864,7 @@ function formatSpanWorker(
// if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules
const tokenInfo = formattingScanner.readTokenInfo(child);
// JSX text shouldn't affect indenting
if (child.kind !== SyntaxKind.JsxText && !isGrammarError(parent, child)) {
if (child.kind !== SyntaxKind.JsxText) {
Debug.assert(tokenInfo.token.end === child.end, "Token end is child end");
consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child);
return inheritedIndentation;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// <reference path='fourslash.ts' />

// @jsx: react-jsxdev
// @Filename: /a.tsx
////[|<div abc={{ foo = 10 }}></div><div abc={{ foo = 10 }}></div>|]

verify.rangeAfterCodeFix(`<><div abc={{ foo = 10 }}></div><div abc={{ foo = 10 }}></div></>`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0);
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edit.applyRefactor({
newContent:
`type /*RENAME*/NewType = {
x: string;
};
};

type Foo<T extends NewType> = T`,
});