Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update replace_step.js #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/replace_step.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ export class ReplaceAroundStep extends Step {
map(mapping) {
let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1)
let gapFrom = mapping.map(this.gapFrom, -1), gapTo = mapping.map(this.gapTo, 1)
if ((from.deleted && to.deleted) || gapFrom < from.pos || gapTo > to.pos) return null
//gapFrom and gapTo must be inside the ranges of [from,to]
gapFrom = Math.max(from.pos,gapFrom), gapTo = Math.min(to.pos,gapTo);
if ((from.deleted && to.deleted) return null
return new ReplaceAroundStep(from.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure)
}

Expand Down