Skip to content

Synchronization issue due to inconsistent EOL sequences in Monaco model #27

@ggrossetie

Description

@ggrossetie

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.

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)

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