widget: test cursor motion in all editor permutations

This commit adds a testcase to catch unexpected panics in the
editor's scroll offset logic introduced by using different
setting combinations that affect editor layout. It also fixes
a panic for single-line editors with alignments other than
text.Start.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2022-02-10 17:41:18 -05:00
committed by Elias Naur
parent ce116abded
commit 9e23412a01
2 changed files with 35 additions and 1 deletions
+1 -1
View File
@@ -644,7 +644,7 @@ func (e *Editor) layout(gtx layout.Context, content layout.Widget) layout.Dimens
var scrollRange image.Rectangle
if e.SingleLine {
scrollRange.Min.X = -e.scrollOff.X
scrollRange.Min.X = min(-e.scrollOff.X, 0)
scrollRange.Max.X = max(0, e.dims.Size.X-(e.scrollOff.X+e.viewSize.X))
} else {
scrollRange.Min.Y = -e.scrollOff.Y