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

Issue:
Visual bugs in `cmd` with stray underlines
### 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.65.0-nightly (f03ce3096 2022-08-08)`

### Clap Version

`4.0.18`

### Minimal reproducible code

```rs
use clap::Command;

fn main() {
    Command::new("repro").get_matches();
}
```

### Steps to reproduce the bug with the above code

`cargo run -- --help`

### Actual Behaviour

![image](https://user-images.githubusercontent.com/13699966/198883926-98b158b4-a581-40fd-b0bd-c845f19404b5.png)

### Expected Behaviour

![image](https://user-images.githubusercontent.com/13699966/198883870-d65286e6-7ce9-4d28-bb94-9b33ad42b328.png)

### Additional Context

The first screenshot shows cmd, the second screenshot shows windows terminal. I wasn't able to trigger this bug in windows terminal but it's worth noting that even in cmd, it doesn't always happen:
![image](https://user-images.githubusercontent.com/13699966/198883969-7bccb1f1-4c99-4d22-b16e-50bb34394e45.png)

### Debug Output

_No response_


Discussion / hints:
Tbat most likely means something is going wrong with termcolor's wincon support as that is most likely the main difference between the two terminals.  Whats especially weird is that there is no reason to put an underline after "information" as we only use underline in headers and so we aren't touching it at that point.

If you want to go an extra step, reproducing this in termcolor and creating an upstream issue would be great.  With #1433, we will most likely be moving off of termcolor though, so we'll need to keep in mind to fix this when we do.
I'm seeing this happen in Wezterm, but specifically only when the help text is printed when the output in the terminal window has reached the bottom. It happens under that condition with both `TERM=wezterm` and `TERM=xterm-256color`.
We also have the same problem when running on Windows 10 Command Prompt or Powershell Prompt.
(It does not have this bug in Windows 11)
Rust: 1.67.1
Clap: 4.1.6

At first it looks like this:
![clap-line-1](https://user-images.githubusercontent.com/71482215/219901066-98d4e59a-f244-4ae1-af73-6b542aacbc53.png)

If I resize the window, the line will extend out from the Options group name:
![clap-line-2](https://user-images.githubusercontent.com/71482215/219901071-d6f75eb7-19d4-469a-9d04-3aca947f9dc0.png)


Fix patch:
diff --git a/src/output/help_template.rs b/src/output/help_template.rs
index 4c7adda9046..e84cd727c79 100644
--- a/src/output/help_template.rs
+++ b/src/output/help_template.rs
@@ -368,7 +368,8 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
                     .get_subcommand_help_heading()
                     .unwrap_or(&default_help_heading),
             );
-            self.header(":\n");
+            self.header(":");
+            self.none("\n");
 
             self.write_subcommands(self.cmd);
         }
@@ -379,7 +380,8 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
             }
             first = false;
             // Write positional args if any
-            self.header("Arguments:\n");
+            self.header("Arguments:");
+            self.none("\n");
             self.write_args(&pos, "Arguments", positional_sort_key);
         }
 
@@ -388,7 +390,8 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
                 self.none("\n\n");
             }
             first = false;
-            self.header("Options:\n");
+            self.header("Options:");
+            self.none("\n");
             self.write_args(&non_pos, "Options", option_sort_key);
         }
         if !custom_headings.is_empty() {
@@ -410,7 +413,9 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
                         self.none("\n\n");
                     }
                     first = false;
-                    self.header(format!("{heading}:\n"));
+                    self.header(heading);
+                    self.header(":");
+                    self.none("\n");
                     self.write_args(&args, heading, option_sort_key);
                 }
             }


Test patch: