Skip to content

[CLI-354] Fix HelpFormatter wrapped description indent - #439

Merged
garydgregory merged 1 commit into
apache:masterfrom
arimu1:fix/CLI-354-help-indent
Aug 22, 2026
Merged

[CLI-354] Fix HelpFormatter wrapped description indent#439
garydgregory merged 1 commit into
apache:masterfrom
arimu1:fix/CLI-354-help-indent

Conversation

@arimu1

@arimu1 arimu1 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Fixes https://issues.apache.org/jira/browse/CLI-354

Wrapped HelpFormatter descriptions are not indented consistently. Continuation lines whose remaining pad equals the indent (restLen == indent) skip the leading indent and apply those spaces on the right instead, so some wrapped lines sit one space left of the others.

TextStyle.pad currently uses restLen > indent. Full-width continuation lines from TextHelpAppendable.makeColumnQueue are already limited to maxWidth - indent, so restLen is exactly indent and the indent is dropped. Changing the comparison to >= matches the reporter's diagnosis and aligns every continuation line.

This does not change wrapping itself. Gary noted that setMaxWidth(6) wrapping is messy; that is left alone.

Tests

  • TextStyleTest.padTestData: remaining pad equal to indent (maxWidth == text.length + indent).
  • HelpFormatterTest.testPrintHelpWrappedDescriptionIndent: long option description; continuation lines share the same indent.

On unfixed master the new pad case expected " Hello world" and got "Hello world ". After the change, mvn test is 991/0 fail/61 skip (Temurin 21). checkstyle:check, pmd:check, and spotbugs:check are clean.

  • 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? Grok 4.6 (xAI) implemented the reporter's one-character > to >= change and the unit tests. No third-party code was copied in.
  • 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.

@garydgregory

Copy link
Copy Markdown
Member

@arimu1 Please rebase on git master which will fix the Javadoc 8 issue.

When remaining pad equals indent, continuation lines dropped the leading
indent and padded the right instead, so some wrapped description lines sat
one space left of the others. Apply indent when restLen >= indent.
@arimu1
arimu1 force-pushed the fix/CLI-354-help-indent branch from 24ca395 to 0254dc3 Compare August 22, 2026 12:50
@arimu1

arimu1 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current master (105ca3fb, commons-parent 104) as requested.

Tip: 0254dc3b

@garydgregory
garydgregory merged commit 0f561e5 into apache:master Aug 22, 2026
10 of 11 checks passed
@garydgregory

Copy link
Copy Markdown
Member

Hello @arimu1

Thank you for the rebase, merged 🚀

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.

2 participants