Skip to content

Inconsistent positions/ranges for files that contain \r\n as a line separator. #35

@DanielCodesphere

Description

@DanielCodesphere

Describe the bug
Codemirror treats the line separator \r\n as a single character which means ranges and positions are different from yjs.
If a file contains \r\n then new characters written after it appear correctly in codemirror but are actually added at the wrong position in the yjs document.
Also adding text directly to the end of the yjs document throws an error because the change will be out of range for codemirror.

It seems like \r\n being only one character is intended behavior for codemirror and positions should be manually adjusted.

To Reproduce
Steps to reproduce the behavior:

  1. Create a file containing 1\r\n2 where \r\n is a line separator, not normal text.
  2. Write another character at the end, it will appear as 1\r\n23 in codemirror but 1\r\n32 in yjs.
  3. Inserting a character at the end of the yjs doc throws a range error when the change is dispatched here.

Expected behavior
Ranges and positions are always consistent between yjs and codemirror.

Environment Information

  • Chromium / Node.js
  • Yjs v13.6.15

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