Skip to content

Commit 589b5b0

Browse files
committed
Fix missing replace inside next sibling
1 parent cddb01b commit 589b5b0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export const findAndReplace =
136136
const replace = pairs[pairIndex][1]
137137
let start = 0
138138
// @ts-expect-error: TS is wrong, some of these children can be text.
139-
let index = parent.children.indexOf(node)
139+
const index = parent.children.indexOf(node)
140140
/** @type {Array<PhrasingContent>} */
141141
let nodes = []
142142
/** @type {number|undefined} */
@@ -188,7 +188,6 @@ export const findAndReplace =
188188

189189
if (position === undefined) {
190190
nodes = [node]
191-
index--
192191
} else {
193192
if (start < node.value.length) {
194193
nodes.push({type: 'text', value: node.value.slice(start)})
@@ -197,7 +196,7 @@ export const findAndReplace =
197196
parent.children.splice(index, 1, ...nodes)
198197
}
199198

200-
return index + nodes.length + 1
199+
return index + nodes.length
201200
}
202201
}
203202
)

0 commit comments

Comments
 (0)