From 61287ac2e13fda6f56b5997202dad1491cbffdbb Mon Sep 17 00:00:00 2001 From: jindw Date: Fri, 22 Oct 2021 16:17:46 +0800 Subject: [PATCH 1/2] Update replace_step.js fix gap range : gapFrom = min(from,gapFrom), gapTo=max(to,gapTo) --- src/replace_step.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/replace_step.js b/src/replace_step.js index f8d8264..d965365 100644 --- a/src/replace_step.js +++ b/src/replace_step.js @@ -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) } From 7a0156207eda2f8c4503a6beb55b04b947c5b826 Mon Sep 17 00:00:00 2001 From: jindw Date: Mon, 25 Oct 2021 14:33:42 +0800 Subject: [PATCH 2/2] Update replace_step.js --- src/replace_step.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/replace_step.js b/src/replace_step.js index d965365..6a7568e 100644 --- a/src/replace_step.js +++ b/src/replace_step.js @@ -143,7 +143,7 @@ export class ReplaceAroundStep extends Step { let gapFrom = mapping.map(this.gapFrom, -1), gapTo = mapping.map(this.gapTo, 1) //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 + if (from.deleted && to.deleted) return null return new ReplaceAroundStep(from.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure) }