widget: redefine >= and ++ on combinedPos

This commit redefines incrementing a combinedPos to either move a single
rune forward, *or* transition from EOL->BOL, *or* both. This allows traversal
of lines without a trailing newline character to reach the position after the
final glyph of content.

Additionally, this commit updates positionGreaterOrEqual to explicitly handle
hard newlines via special-case logic, allowing lines without a hard newline to
avoid the newline-based short-circuit logic that would prevent them from iteratively
reaching the combinedPos following the final glyph on the line.

Fixes: https://todo.sr.ht/~eliasnaur/gio/400

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2022-10-17 07:59:24 -04:00
committed by Elias Naur
parent 2340664570
commit f7c14e9964
2 changed files with 65 additions and 40 deletions
+3 -3
View File
@@ -231,6 +231,9 @@ func TestIncrementPosition(t *testing.T) {
if input.clusterIndex > output.clusterIndex {
t.Errorf("iteration %d advanced clusterIndex incorrectly: input %d output %d", i, input.clusterIndex, output.clusterIndex)
}
if output.runes != input.runes+1 {
t.Errorf("iteration %d advanced runes incorrectly: input %d output %d", i, input.runes, output.runes)
}
} else {
if input.y >= output.y {
t.Errorf("iteration %d advanced the wrong way on y axis: input %v(%d) output %v(%d)", i, input.y, input.y, output.y, output.y)
@@ -252,9 +255,6 @@ func TestIncrementPosition(t *testing.T) {
t.Errorf("iteration %d should have zeroed lineCol.X, got: %d", i, output.lineCol.X)
}
}
if output.runes != input.runes+1 {
t.Errorf("iteration %d advanced runes incorrectly: input %d output %d", i, input.runes, output.runes)
}
input = output
}
})