-
-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Checklist
- Are you reporting a bug? Use github issues for bug reports and feature requests. For general questions, please use https://discuss.yjs.dev/
- Try to report your issue in the correct repository. Yjs consists of many modules. When in doubt, report it to https://github.com/yjs/yjs/issues/
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.
Line 140 in 33d1583
index += op.retain |
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)