community icon indicating copy to clipboard operation
community copied to clipboard

Modify layout_text() to fix bug in how the text is cut

Open RobinPicard opened this issue 3 years ago • 0 comments

This PR aims at answering the following issue: https://github.com/kivy/kivy/issues/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.

RobinPicard avatar Sep 05 '22 22:09 RobinPicard