Mobile: Fixes #9477: Fix inline code at beginning of line in table breaks formatting #9478
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
CodeMirror 6 requires decorations to be added in sorted order. First by the start position of a decoration, next by length.
Joplin's decorator extension was only sorting by start position. As such, in some cases, it could add decorations in an incorrect order.
This pull request fixes #9477 by sorting by length if start positions are equal.
Notes
The example given in #9477 is a regression from the previous version of the mobile app (2.12.3):
Previously, the mobile editor didn't render tables in a monospace font. As such, it didn't attempt to add a decoration to table rows.
Full-line decorations have length
0
. For the above table, Joplin adds the decorations to`foo`
and to the table row in the wrong order. This throws an exception, causing no decorations to be added.Testing
This pull request contains an automated test, but has been tested manually with the following steps: