Skip to content

Commit

Permalink
fix: fix mappes positions for paste rules, fix #2002
Browse files Browse the repository at this point in the history
  • Loading branch information
philippkuehn committed Oct 8, 2021
1 parent ed00dbb commit 770c4e1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/PasteRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -118,7 +118,7 @@ function run(config: {
})
})
})
}, from)
})
}

/**
Expand All @@ -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
}

Expand All @@ -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,
Expand Down

0 comments on commit 770c4e1

Please sign in to comment.