Skip to content

Commit 36ad9b9

Browse files
committed
fix; improve picking of special position of jsx content!
1 parent 845c4ff commit 36ad9b9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

typescript/src/specialCommands/handle.ts

+7
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ export default (
132132
let targetNode: undefined | ts.Node | [number, number]
133133
if (ts.isIdentifier(node) && node.parent) {
134134
node = node.parent
135+
if (ts.isJsxExpression(node)) node = node.parent
136+
if (ts.isJsxAttributeLike(node)) node = node.parent
137+
if (ts.isJsxAttributes(node)) node = node.parent
135138
if (ts.isPropertyAssignment(node)) {
136139
targetNode = node.initializer
137140
} else if ('body' in node) {
@@ -140,6 +143,10 @@ export default (
140143
const pos = node.end
141144
targetNode = [pos, pos]
142145
}
146+
if (ts.isJsxClosingElement(node) || ts.isJsxClosingFragment(node)) {
147+
const { pos } = node
148+
targetNode = [pos, pos]
149+
}
143150
}
144151

145152
if (!targetNode) {

0 commit comments

Comments
 (0)