Skip to content
Permalink
Browse files

Make replaceRange check whether replace created any new steps

FIX: `replaceRange` now more aggressively expands the replaced region
if `replace` fails to place the slice.
  • Loading branch information...
marijnh committed Aug 26, 2019
1 parent b183da4 commit b43958563b49e7fea585291829742171fbd7fcd2
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/replace.js
@@ -473,7 +473,15 @@ Transform.prototype.replaceRange = function(from, to, slice) {
}
}

return this.replace(from, to, slice)
let startSteps = this.steps.length
for (let i = targetDepths.length - 1; i >= 0; i--) {
this.replace(from, to, slice)
if (this.steps.length > startSteps) break
let depth = targetDepths[i]
if (i < 0) continue
from = $from.before(depth); to = $to.after(depth)
}
return this
}

function closeFragment(fragment, depth, oldOpen, newOpen, parent) {

0 comments on commit b439585

Please sign in to comment.
You can’t perform that action at this time.