Checklist
Describe the bug
There is a synchronization issue when the EOL (end-of-line) sequence is not explicitly defined in the Monaco model. On Windows, the default EOL is \r\n, whereas on Linux and macOS, it is \n.
This causes inconsistencies because y-monaco uses an offset provided by event.delta.retain, and that offset differs depending on the operating system.
To Reproduce
Consider a text with two line breaks (i.e., three empty lines). A Linux user modifies the text on the third line at offset 2 (\n\n). This change is propagated to a Windows user, but it affects line 2 instead, because offset 2 corresponds to \r\n.
Expected behavior
At the very least, this behavior should be documented in the README. Ideally, the EOL sequence should be enforced when constructing the MonacoBinding:
model.setEOL(monaco.editor.EndOfLineSequence.LF)
Checklist
Describe the bug
There is a synchronization issue when the EOL (end-of-line) sequence is not explicitly defined in the Monaco model. On Windows, the default EOL is
\r\n, whereas on Linux and macOS, it is\n.This causes inconsistencies because
y-monacouses an offset provided byevent.delta.retain, and that offset differs depending on the operating system.y-monaco/src/y-monaco.js
Line 140 in 33d1583
To Reproduce
Consider a text with two line breaks (i.e., three empty lines). A Linux user modifies the text on the third line at offset 2 (
\n\n). This change is propagated to a Windows user, but it affects line 2 instead, because offset 2 corresponds to\r\n.Expected behavior
At the very least, this behavior should be documented in the README. Ideally, the EOL sequence should be enforced when constructing the MonacoBinding: