Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify layout fix bug in how long text without space is cut #7999

Merged
merged 1 commit into from Oct 3, 2022

Conversation

RobinPicard
Copy link
Contributor

This PR aims at answering the following issue: #7998

As explained in the issue, the function layout_text cuts a line at the wrong place in certain cases. Upon reading the code source for this function, I came to the conclusion that it's probably caused by the fact that the value of the variable is_space is not reset to 0 at each iteration over the lines. I think so because:

  • The change I propose below solved the example presented in the issue and did not cause any problem in the tests I've done (which consisted in trying out many random strings)
  • I can't make sense of why we would initially give the value 0 to is_space but then not set this starting value again for each line leading to a situation in which lines can influence each other's layout
    However, there's a lot I do not understand in this file, so maybe there's just something I don't get

Maintainer merge checklist

  • Title is descriptive/clear for inclusion in release notes.
  • Applied a Component: xxx label.
  • Applied the api-deprecation or api-break label.
  • Applied the release-highlight label to be highlighted in release notes.
  • Added to the milestone version it was merged into.
  • Unittests are included in PR.
  • Properly documented, including versionadded, versionchanged as needed.

Copy link
Member

@tshirtman tshirtman left a comment

Choose a reason for hiding this comment

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

Explanation looks logical to me and the fix quite straightforward, so I'm inclined to merge it.
If possible, a test for that case preventing regression would be nice.

Copy link
Member

@matham matham left a comment

Choose a reason for hiding this comment

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

The fix makes sense to me.

@matham matham added this to the 2.2.0 milestone Oct 3, 2022
@matham matham changed the title Modify layout_text() to fix bug in how the text is cut Modify layout fix bug in how long text without space is cut Oct 3, 2022
@matham matham merged commit e501a07 into kivy:master Oct 3, 2022
@welcome
Copy link

welcome bot commented Oct 3, 2022

Congrats on merging your first pull request! 🎉🎉🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants