Thank you for reporting this — this issue is related to the beta markdown editor. Specifically, it's coming from this line:
I was able to reproduce this error with this part of Joplin's code, a cursor at the end of a note, and CRLF line endings. (Example on CodeMirror's try page.)
In the beta editor, cursor positions are represented by numbers. For example, if the cursor was at the end of a document with content 123456, the cursor would have position 6. It seems, however, that while a CRLF line ending is two JavaScript characters, it's just one cursor increment.
I've tried reproducing this with a multi-character symbol ("
"), but haven't been able to.
To fix this, Joplin should use EditorState.toText(...).length to determine the maximum position, rather than using the string length. In CodeMirror's try-it editor, this seems to fix the issue.
1 Like