Fix #1041: Wrap long lines based on a settable maximum line width #1355
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.
Previously, rendering glyphs in the scene depended solely on
glyphLines
property, which originates from text entry of side panel.And I recognized that to handle alignments, advance width of glyphs and total line lengths were already being tracked.
By using stack and pushing the "remaining line" on the top of the stack when the line length exceeds certain threshold, it was possible to implement the line wrapping algorithm.
--
But the problem is that currently "selection API" depends on "indices", and various codes accessing the current selected glyphs use these line and glyph indices to get glyph info out of
glyphLines
property.This leads to a bug:
when I select
b
from the "wrapped second line", and edit it,d
gets edited because it is the second glyph of the second line, with respect toglyphLines
Therefore I handled this case by changing related codes to use
positionedLines
instead ofglyphLines
. Since type signatures of two data differs, some transforming is done. This is what second commit is about.But it feels too much "ad hoc" for me, so any suggestions or reviews will be very helpful