widget: test positionGreaterOrEqual

This commit adds an exhaustive test case for the positionGreaterOrEqual
helper function that our text widgets use to compare locations within
shaped text.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2022-10-13 13:35:48 -04:00
committed by Elias Naur
parent 64db3720fc
commit dee3cc44f9
2 changed files with 93 additions and 7 deletions
+2 -1
View File
@@ -1000,7 +1000,8 @@ func (e *Editor) indexPosition(pos combinedPos) combinedPos {
}
// positionGreaterOrEqual reports whether p1 >= p2 according to the non-zero fields
// of p2. All fields of p1 must be a consistent and valid.
// of p2. All fields of p1 must be a consistent and valid. The clusterIndex field
// is never considered, as it is a line-local property.
func positionGreaterOrEqual(lines []text.Line, p1, p2 combinedPos) bool {
l := lines[p1.lineCol.Y]
endCol := l.Layout.Runes.Count - 1