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

This commit is contained in:
Ron Buckton
2023-02-16 21:34:58 -05:00
committed by GitHub
parent 3980b5b2b1
commit fd0370822f
3 changed files with 10 additions and 3 deletions

View File

@@ -804,7 +804,7 @@ function formatSpanWorker(
isFirstListItem?: boolean): number {
Debug.assert(!nodeIsSynthesized(child));
if (nodeIsMissing(child)) {
if (nodeIsMissing(child) || isGrammarError(parent, child)) {
return inheritedIndentation;
}
@@ -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;

View File

@@ -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);

View File

@@ -11,7 +11,7 @@ edit.applyRefactor({
newContent:
`type /*RENAME*/NewType = {
x: string;
};
};
type Foo<T extends NewType> = T`,
});