From 770c4e18e19504f4c44feb85b7d202fcc5201b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 8 Oct 2021 22:40:06 +0200 Subject: [PATCH] fix: fix mappes positions for paste rules, fix #2002 --- packages/core/src/PasteRule.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/PasteRule.ts b/packages/core/src/PasteRule.ts index 13e16b67dee..54b60efa4f8 100644 --- a/packages/core/src/PasteRule.ts +++ b/packages/core/src/PasteRule.ts @@ -104,7 +104,7 @@ function run(config: { return } - const start = resolvedFrom + match.index + const start = resolvedFrom + match.index + 1 const end = start + match[0].length const range = { from: state.tr.mapping.map(start), @@ -118,7 +118,7 @@ function run(config: { }) }) }) - }, from) + }) } /** @@ -141,7 +141,7 @@ export function pasteRulesPlugin(rules: PasteRule[]): Plugin { const from = before.content.findDiffStart(doc.content) const to = before.content.findDiffEnd(doc.content) - if (!from || !to) { + if (!from || !to || from === to.b) { return } @@ -155,7 +155,7 @@ export function pasteRulesPlugin(rules: PasteRule[]): Plugin { run({ state: chainableState, - from, + from: Math.max(from - 1, 0), to: to.b, rules, plugin,