Skip to content

In case of the end of the node,relativePositionToAbsolutePosition conversion error #194

@Gggpound

Description

@Gggpound

Please save me some time and use the following template. In 90% of all issues I can't reproduce the problem because I don't know what exactly you are doing, in which environment, or which y-* version is responsible. Just use the following template even if you think the problem is obvious.

Checklist

Describe the bug
When I use relativePositionToAbsolutePosition to create a relative index between a->b based on a certain node, as long as b reaches the end of this node, then the b in a->b obtained by absolutePositionToRelativePosition will be incorrect, with the index position being 1 less than expected.

To Reproduce
Steps to reproduce the behavior:

  1. Create a relative position
const fromRel = absolutePositionToRelativePosition(fromRelPure, yXmlElement, mapping)
// to is the xmlElement node`s endPos
const toRel = absolutePositionToRelativePosition(toRelPure, yXmlElement, mapping)
  1. Convert relative position to absolute position
const absFrom = relativePositionToAbsolutePosition(doc, xmlElement, createRelativePositionFromJSON(from), mapping)
 
const absFTo = relativePositionToAbsolutePosition(doc, xmlElement, createRelativePositionFromJSON(to), mapping)

Expected behavior
The index conversion is consistent

Screenshots
If applicable, add screenshots to help explain your problem.

Environment Information

  • Browser / Node.js [e.g. Chrome, Firefox, Node.js]
  • Yjs version and the versions of the y-* modules you are using [e.g. yjs v13.0.1, y-webrtc v1.2.1]. Use npm ls yjs to find out the exact version you are using.

Additional context
Add any other context about the problem here.

  • I'm a sponsor 💖
  • This issue is a blocker for my project.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions