Skip to content

Commit 3638738

Browse files
committed
Fix missing replace inside next sibling
Closes GH-3.
1 parent 474546f commit 3638738

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function findAndReplace(tree, find, replace, options) {
116116
const find = pairs[pairIndex][0]
117117
const replace = pairs[pairIndex][1]
118118
let start = 0
119-
let index = parent.children.indexOf(node)
119+
const index = parent.children.indexOf(node)
120120
/** @type {Array<Content>} */
121121
let nodes = []
122122
/** @type {number|undefined} */
@@ -167,7 +167,6 @@ export function findAndReplace(tree, find, replace, options) {
167167

168168
if (position === undefined) {
169169
nodes = [node]
170-
index--
171170
} else {
172171
if (start < node.value.length) {
173172
nodes.push({type: 'text', value: node.value.slice(start)})
@@ -176,7 +175,7 @@ export function findAndReplace(tree, find, replace, options) {
176175
parent.children.splice(index, 1, ...nodes)
177176
}
178177

179-
return index + nodes.length + 1
178+
return index + nodes.length
180179
}
181180
}
182181

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
"typeCoverage": {
7878
"atLeast": 100,
7979
"detail": true,
80-
"detail": true,
8180
"ignoreNested": true
8281
}
8382
}

0 commit comments

Comments
 (0)