Skip to content

Commit

Permalink
fix; improve picking of special position of jsx content!
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Jan 19, 2024
1 parent 845c4ff commit 36ad9b9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions typescript/src/specialCommands/handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ export default (
let targetNode: undefined | ts.Node | [number, number]
if (ts.isIdentifier(node) && node.parent) {
node = node.parent
if (ts.isJsxExpression(node)) node = node.parent
if (ts.isJsxAttributeLike(node)) node = node.parent
if (ts.isJsxAttributes(node)) node = node.parent
if (ts.isPropertyAssignment(node)) {
targetNode = node.initializer
} else if ('body' in node) {
Expand All @@ -140,6 +143,10 @@ export default (
const pos = node.end
targetNode = [pos, pos]
}
if (ts.isJsxClosingElement(node) || ts.isJsxClosingFragment(node)) {
const { pos } = node
targetNode = [pos, pos]
}
}

if (!targetNode) {
Expand Down

0 comments on commit 36ad9b9

Please sign in to comment.