Skip to content

Commit 8fabb2d

Browse files
authored
normalize eol for monaco client as well. (#195)
Signed-off-by: Jonah Iden <jonah.iden@typefox.io>
1 parent eb03f20 commit 8fabb2d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

packages/open-collaboration-monaco/src/collaboration-instance.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ export class CollaborationInstance implements Disposable {
496496
value = debounce(() => {
497497
this.yjsMutex(() => {
498498
const yjsText = this.yjs.getText(path);
499-
const newContent = yjsText.toString();
499+
const newContent = this.adjustEol(yjsText.toString(), document.getEndOfLineSequence());
500500
if (newContent !== document.getValue()) {
501501
this.updateDocumentContent(document, newContent);
502502
}
@@ -657,4 +657,9 @@ export class CollaborationInstance implements Disposable {
657657
return decoder.decode(file.content);
658658
}
659659
}
660+
661+
private adjustEol(text: string, eol: monaco.editor.EndOfLineSequence): string {
662+
const newEol = eol === monaco.editor.EndOfLineSequence.LF ? '\n' : '\r\n';
663+
return text.replace(/\r?\n/g, newEol);
664+
}
660665
}

0 commit comments

Comments
 (0)