Repository: clap-rs/clap (language: rust)

Issue:
Subcommand about text is incorrectly wrapped
### Please complete the following tasks

- [X] I have searched the [discussions](https://github.com/clap-rs/clap/discussions)
- [X] I have searched the [open](https://github.com/clap-rs/clap/issues) and [rejected](https://github.com/clap-rs/clap/issues?q=is%3Aissue+label%3AS-wont-fix+is%3Aclosed) issues

### Rust Version

rustc 1.80.0 (051478957 2024-07-21)

### Clap Version

4.5.11

### Minimal reproducible code

```rust
use clap::{Parser, Subcommand};

#[derive(Debug, Parser)]
struct Args {
    #[clap(subcommand)]
    sub: Command,
}

#[derive(Debug, Subcommand)]
enum Command {
    /// About text for subcommand that's just a little bit too long and so needs to be wrapped
    CmdName,
}

fn main() {
    Args::parse();
}
```

### Steps to reproduce the bug with the above code

`cargo run -- -h` on a narrow enough terminal (examples below are 60 cols).

### Actual Behaviour

```
Commands:
  cmd-name  About text for subcommand that's just a
                little bit too long and so needs to be
                wrapped
  help      Print this message or the help of the given
                subcommand(s)
```

### Expected Behaviour

```
Commands:
  cmd-name  About text for subcommand that's just a
            little bit too long and so needs to be
            wrapped
  help      Print this message or the help of the given
            subcommand(s)
```

### Additional Context

It works fine when you have a longer subcommand name.
```
Commands:
  a-much-longer-cmd-name
          About text for subcommand that's just a little bit
          too long and so needs to be wrapped
  help
          Print this message or the help of the given
          subcommand(s)
```

### Debug Output

_No response_


Discussion / hints:

Fix patch:
diff --git a/clap_builder/src/output/help_template.rs b/clap_builder/src/output/help_template.rs
index f3a2b02ed33..3abeab1487a 100644
--- a/clap_builder/src/output/help_template.rs
+++ b/clap_builder/src/output/help_template.rs
@@ -650,7 +650,7 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
 
         let spaces = if next_line_help {
             TAB.len() + NEXT_LINE_INDENT.len()
-        } else if let Some(true) = arg.map(|a| a.is_positional()) {
+        } else if arg.map(|a| a.is_positional()).unwrap_or(true) {
             longest + TAB_WIDTH * 2
         } else {
             longest + TAB_WIDTH * 2 + 4 // See `fn short` for the 4


Test patch:
diff --git a/tests/builder/help.rs b/tests/builder/help.rs
index 0169bb28538..fb203b0e59e 100644
--- a/tests/builder/help.rs
+++ b/tests/builder/help.rs
@@ -566,10 +566,19 @@ fn wrapped_help() {
                 .long("no-git-push")
                 .action(ArgAction::SetTrue)
                 .help("Do not push generated commit and tags to git remote"),
+        )
+        .subcommand(
+            Command::new("sub1")
+                .about("One two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen")
         );
 
     let expected = str![[r#"
-Usage: test [OPTIONS]
+Usage: test [OPTIONS] [COMMAND]
+
+Commands:
+  sub1  One two three four five six seven eight nine ten eleven
+        twelve thirteen fourteen fifteen
+  help  Print this message or the help of the given subcommand(s)
 
 Options:
   -a, --all            Also do versioning for private crates (will
@@ -614,10 +623,19 @@ fn unwrapped_help() {
                 .long("no-git-push")
                 .action(ArgAction::SetTrue)
                 .help("Do not push generated commit and tags to git remote"),
+        )
+        .subcommand(
+            Command::new("sub1")
+                .about("One two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen")
         );
 
     let expected = str![[r#"
-Usage: test [OPTIONS]
+Usage: test [OPTIONS] [COMMAND]
+
+Commands:
+  sub1  One two three four five six seven eight nine ten eleven
+        twelve thirteen fourteen fifteen
+  help  Print this message or the help of the given subcommand(s)
 
 Options:
   -a, --all            Also do versioning for private crates (will