From 912ddb95f8de6050fd5e9c0f267b28a8bee689f5 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 9 Feb 2022 21:04:18 +0100 Subject: [PATCH] widget: fix build on Go 1.17 Signed-off-by: Elias Naur --- widget/editor.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/widget/editor.go b/widget/editor.go index daba9a1d..044a57e2 100644 --- a/widget/editor.go +++ b/widget/editor.go @@ -742,9 +742,15 @@ func (e *Editor) PaintCaret(gtx layout.Context) { } } +// TODO: copied from package math. Remove when Go 1.18 is minimum. +const ( + intSize = 32 << (^uint(0) >> 63) // 32 or 64 + maxInt = 1<<(intSize-1) - 1 +) + // Len is the length of the editor contents, in runes. func (e *Editor) Len() int { - end := e.closestPosition(combinedPos{runes: math.MaxInt}) + end := e.closestPosition(combinedPos{runes: maxInt}) return end.runes } @@ -1051,7 +1057,7 @@ func (e *Editor) moveStart(selAct selectionAction) { func (e *Editor) moveEnd(selAct selectionAction) { caret := e.closestPosition(combinedPos{runes: e.caret.start}) - caret = e.closestPosition(combinedPos{lineCol: screenPos{X: math.MaxInt, Y: caret.lineCol.Y}}) + caret = e.closestPosition(combinedPos{lineCol: screenPos{X: maxInt, Y: caret.lineCol.Y}}) e.caret.start = caret.runes l := e.lines[caret.lineCol.Y] a := align(e.Alignment, l.Width, e.viewSize.X)