Skip to content

Commit cf15d48

Browse files
authored
Merge pull request #5893 from 8LWXpg/patch-2
fix(complete): Check if help string is empty
2 parents 7e54542 + 6ffc88f commit cf15d48

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

clap_complete/src/aot/shells/powershell.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,13 @@ fn escape_string(string: &str) -> String {
6363
}
6464

6565
fn escape_help<T: ToString>(help: Option<&StyledStr>, data: T) -> String {
66-
match help {
67-
Some(help) => escape_string(&help.to_string().replace('\n', " ")),
68-
_ => data.to_string(),
66+
if let Some(help) = help {
67+
let help_str = help.to_string();
68+
if !help_str.is_empty() {
69+
return escape_string(&help_str.replace('\n', " "));
70+
}
6971
}
72+
data.to_string()
7073
}
7174

7275
fn generate_inner(p: &Command, previous_command_name: &str) -> String {

0 commit comments

Comments
 (0)