Skip to content

Conversation

@benoitkugler
Copy link
Contributor

@benoitkugler benoitkugler commented Dec 8, 2025

When using go-text to wrap text ending with spaces, I want to put the final space on the first line when it fits (speaking about the advance). This requirement is somewhere between DisableTrailingWhitespaceTrim=true and DisableTrailingWhitespaceTrim=false : disabling trimming will miss wrapping opportunities, enabling it will always remove the space advance even when it could fit.

The workaround I've found is to to enable trimming, but to check after if the advance including the space would have fit.

The cleanest way to do so seems to expose the actual advance that was trimmed: that is implemented in this PR.

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.

Seems like a reasonable feature to me! Implementation is solid too. Thanks for the test!

Copy link
Contributor

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

Great :)

Looks like there is a conflict with other items recently merged :(

@benoitkugler benoitkugler merged commit 2f8ad27 into main Dec 23, 2025
14 checks passed
@benoitkugler benoitkugler deleted the expose-trimed-whitespace branch December 23, 2025 12:51
benoitkugler added a commit that referenced this pull request Dec 23, 2025
* [shaping] expose the space we trim when wrapping with TrimWhiteSpace enabled

* minor typos

* Replace setup-go-faster action with setup-go

* Replace setup-go-faster action with setup-go

* [shaping] expose the space we trim when wrapping with TrimWhiteSpace enabled

* minor typos

* remove debug fmt.Println
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