mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
fix(50068): Refactors trigger debug failure when JSX text has a ' and a tag on the same line. (#51299)
* fix(50068): rescan JsxText on JsxElement context * fix lint errors * add tests
This commit is contained in:
@@ -126,7 +126,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
function shouldRescanJsxText(node: Node): boolean {
|
||||
return isJsxText(node);
|
||||
return isJsxText(node) || isJsxElement(node) && lastTokenInfo?.token.kind === SyntaxKind.JsxText;
|
||||
}
|
||||
|
||||
function shouldRescanSlashToken(container: Node): boolean {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @jsx: preserve
|
||||
// @filename: a.tsx
|
||||
////function Foo() {
|
||||
//// const foo = [
|
||||
//// /*a*/<div>' <span></span></div>/*b*/
|
||||
//// ];
|
||||
////}
|
||||
|
||||
goTo.file("a.tsx");
|
||||
goTo.select("a", "b");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Extract Symbol",
|
||||
actionName: "constant_scope_1",
|
||||
actionDescription: "Extract to constant in global scope",
|
||||
newContent:
|
||||
`const newLocal = <div>' <span></span></div>;
|
||||
function Foo() {
|
||||
const foo = [
|
||||
/*RENAME*/newLocal
|
||||
];
|
||||
}`
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @jsx: preserve
|
||||
// @filename: a.tsx
|
||||
////function Foo() {
|
||||
//// const foo = [
|
||||
//// /*a*/<div>'" <span></span></div>/*b*/
|
||||
//// ];
|
||||
////}
|
||||
|
||||
goTo.file("a.tsx");
|
||||
goTo.select("a", "b");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Extract Symbol",
|
||||
actionName: "constant_scope_1",
|
||||
actionDescription: "Extract to constant in global scope",
|
||||
newContent:
|
||||
`const newLocal = <div>'" <span></span></div>;
|
||||
function Foo() {
|
||||
const foo = [
|
||||
/*RENAME*/newLocal
|
||||
];
|
||||
}`
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @jsx: preserve
|
||||
// @filename: a.tsx
|
||||
////function Foo() {
|
||||
//// const foo = [
|
||||
//// /*a*/<div>text' <span>text' </span>text ' text " </div>/*b*/
|
||||
//// ];
|
||||
////}
|
||||
|
||||
goTo.file("a.tsx");
|
||||
goTo.select("a", "b");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Extract Symbol",
|
||||
actionName: "constant_scope_1",
|
||||
actionDescription: "Extract to constant in global scope",
|
||||
newContent:
|
||||
`const newLocal = <div>text' <span>text' </span>text ' text " </div>;
|
||||
function Foo() {
|
||||
const foo = [
|
||||
/*RENAME*/newLocal
|
||||
];
|
||||
}`
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @jsx: preserve
|
||||
// @filename: a.tsx
|
||||
////function Foo() {
|
||||
//// const foo = [
|
||||
//// /*a*/<div>' {1}</div>/*b*/
|
||||
//// ];
|
||||
////}
|
||||
|
||||
goTo.file("a.tsx");
|
||||
goTo.select("a", "b");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Extract Symbol",
|
||||
actionName: "constant_scope_1",
|
||||
actionDescription: "Extract to constant in global scope",
|
||||
newContent:
|
||||
`const newLocal = <div>' {1}</div>;
|
||||
function Foo() {
|
||||
const foo = [
|
||||
/*RENAME*/newLocal
|
||||
];
|
||||
}`
|
||||
});
|
||||
Reference in New Issue
Block a user