Atomic CRLF sequences

Hi!

I’m using CodeMirror to display texts that can contain \r\n sequences. I’d like for these \r\n sequences to be atomic but I haven’t figured out the best way to do this.

A few things I tried:

  • Using EditorState.lineSeparator.of("\r\n"): This seems to transform \r\n into \n, which isn’t what I want since I need the \r\n sequences to remain intact.
  • MatchDecorator using the /\r\n/g regexp: This doesn’t work as line breaks aren’t part of the text.

The endgoal I’d like is for the user to be able to type/delete \r\n as if it were a single character, while keeping the original text intact (aka no normalization of newlines).

Would love any ideas on how to achieve this!

Line separators are automatically atomic—the editor treats them as a single position (they don’t count as 2 units when computing document offsets) and they only show up when you serialize the document to a string (or parse from a string).