Skip to content

Commit

Permalink
Fix extendMarkRange doesn't work when cursor is at end of mark
Browse files Browse the repository at this point in the history
  • Loading branch information
JDinABox authored and bdbch committed May 17, 2022
1 parent 9430ca9 commit 0fb68af
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/helpers/getMarkRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export function getMarkRange(
return
}

const start = $pos.parent.childAfter($pos.parentOffset)
let start = $pos.parent.childAfter($pos.parentOffset)

if ($pos.parentOffset === start.offset && start.offset !== 0) {
start = $pos.parent.childBefore($pos.parentOffset)
}

if (!start.node) {
return
Expand All @@ -41,7 +45,7 @@ export function getMarkRange(
return
}

let startIndex = $pos.index()
let startIndex = start.index
let startPos = $pos.start() + start.offset
let endIndex = startIndex + 1
let endPos = startPos + start.node.nodeSize
Expand Down

0 comments on commit 0fb68af

Please sign in to comment.