Skip to content

fix infinite loop in TextHelpAppendable.makeColumnQueue at width 1 - #442

Open
rootvector2 wants to merge 1 commit into
apache:masterfrom
rootvector2:text-help-wrap-width-one
Open

rootvector2 wants to merge 1 commit into
apache:masterfrom
rootvector2:text-help-wrap-width-one

Conversation

@rootvector2

Copy link
Copy Markdown
Contributor

makeColumnQueue never terminates when the usable width is 1 because indexOfWrap chops a line without whitespace at limit - 1, which is startPos, and appendList reaches that width (or 0, which throws) for any entry with a line break of at most 8 characters since it sizes the wrap width from the entry rather than the page, so indexOfWrap now always consumes one character and list entries wrap at the configured width; found while reviewing the help wrapping after #437.

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute? Claude Code helped write the fix, the tests, and this description.
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

indexOfWrap chops a line without whitespace at limit - 1, which is startPos when the width is 1, so makeColumnQueue re-reads the same position and grows its queue until the heap is exhausted. appendList hits this with default settings for an 8 character entry containing a line break because it sizes the wrap width from the entry length, and throws for shorter entries. Always consume at least one character in indexOfWrap and wrap list entries at the configured width.
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.

1 participant