mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 00:45:35 +00:00
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:
+3
-3
@@ -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
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user