Skip to content

fix oneline overflow#226

Closed
zodimo wants to merge 1 commit intogo-text:mainfrom
zodimo:wrap-overflow
Closed

fix oneline overflow#226
zodimo wants to merge 1 commit intogo-text:mainfrom
zodimo:wrap-overflow

Conversation

@zodimo
Copy link
Contributor

@zodimo zodimo commented Feb 9, 2026

I have discovered this bug when updating go-text/typesetting to v0.3.3 and the gioui/widget.Editor SingleLine=true stopped working and text was displayed vertical one character per line. I have traced it to widget/text.go line 246-254.

	maxWidth := gtx.Constraints.Max.X
	if e.SingleLine {
		maxWidth = math.MaxInt
	}
	minWidth := gtx.Constraints.Min.X
	if maxWidth != e.params.MaxWidth {
		e.params.MaxWidth = maxWidth
		e.invalidate()
	}

Which caused and overflow in text/gotext.go line 514.

	return s.wrapper.WrapParagraph(wc, params.MaxWidth, txt, shaping.NewSliceIterator(s.shapeText(params.PxPerEm, params.Locale, txt)))

which progressed to shaping/wrapping.go from github.com/go-text/typesetting v 0.3.3, where the overflow occurs. fixed.I(maxWidth) -> -64 when maxWidth is math.MaxInt

func (l *LineWrapper) WrapParagraph(config WrapConfig, maxWidth int, paragraph []rune, runs RunIterator) (_ []Line, truncated int) {
	return l.WrapParagraphF(config, fixed.I(maxWidth), paragraph, runs)
}

The error before the fix was applied.

--- FAIL: TestWrapping_oneLine_overflow_bug (0.00s)
    wrapping_test.go:3614: expected one line, got 2
    wrapping_test.go:3620: expected no line, got 2

I have created a safety check for the overflow and created a test to verify

Copy link
Contributor

@benoitkugler benoitkugler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good point, thank you for the detailed explanation ! This is indeed an oversight from #209. I think the fix is accurate, thanks !

Copy link
Member

@whereswaldon whereswaldon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!

@benoitkugler
Copy link
Contributor

benoitkugler commented Feb 10, 2026

Does anyone understand why some checks are not running, preventing the merge ?

It seems like the checks on @zodimo fork have not completed, perhaps you could try to re-run ?

@zodimo
Copy link
Contributor Author

zodimo commented Feb 11, 2026

Does anyone understand why some checks are not running, preventing the merge ?

It seems like the checks on @zodimo fork have not completed, perhaps you could try to re-run ?

I have re-run them and all passed.

Selection_2026-02-11-02

@andydotxyz
Copy link
Contributor

I cannot kick this Actions as it is still waiting - perhaps an empty commit will force it to reset?

@zodimo zodimo marked this pull request as draft February 12, 2026 21:00
@zodimo zodimo marked this pull request as ready for review February 12, 2026 21:00
@andydotxyz
Copy link
Contributor

Closing as duplicate of replacement #229

@andydotxyz andydotxyz closed this Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants