Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: extendMarkRange doesn't work when cursor is at end of mark, despite isActive() returning true for that mark #2717

Merged
merged 2 commits into from
May 17, 2022
Merged
Changes from all commits
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
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