Closed Blakeinstein closed 3 years ago
@Blakeinstein Thanks for logging this issue and this has been a long overdue. We should be able to have a consistent way to handle different line endings natively from Firepad itself. But for the time being, you could do something like this in your monaco instance in your app:
+ editor.getModel().setEOL(monaco.editor.EndOfLineSequence.LF);
- editor.setValue(stringContent);
+ editor.getModel().applyEdits([
{
range: editor.getModel().getFullRange(),
text: lineContent.join("\n"),
}
])
and get it resolved. We do the same at Hackerrank.
I should also do this when I update options and or language?
Only if you update Monaco Model along with them.
+ editor.getModel().setEOL(monaco.editor.EndOfLineSequence.LF); - editor.setValue(stringContent); + editor.getModel().applyEdits([ { range: editor.getModel().getFullRange(), text: lineContent.join("\n"), } ])
I assume all I need are the lines marked with +
? What is line content? editor.getModel().getLinesContent()
?
+ editor.getModel().setEOL(monaco.editor.EndOfLineSequence.LF); - editor.setValue(stringContent); + editor.getModel().applyEdits([ { range: editor.getModel().getFullRange(), text: lineContent.join("\n"), } ])
I assume all I need are the lines marked with
+
? What is line content?editor.getModel().getLinesContent()
?
I am assuming you know changes that you want to update as string[]
in lineContent
. You can use this API as well. stringContent
is the whole content in string
.
-
marked statements must be removed.
Ended up doing the following, and so far it looks like it works.
editor.getModel().setEOL(monaco.editor.EndOfLineSequence.LF)
editor.getModel().applyEdits([
{
range: editor.getModel().getFullModelRange(),
text: editor.getModel().getLinesContent().join('\n')
}
])
You can close the issue, or keep it open as I see that you guys plan to provide a native solution for this. Thanks!
Closing this for now. Let me know if any new problem comes up in this.
Version info
Firebase: 8.9.1
Firepad: 0.2.0
Monaco: 0.20.0
Test case
Duplicate of https://github.com/FirebaseExtended/firepad/issues/315
Steps to reproduce
Expected behavior
Consistent behaviour
Actual behavior
Cannot send changes from windows