mirror of
https://github.com/clap-rs/clap
synced 2024-11-14 16:47:21 +00:00
fix(Help Wrapping): fixes a regression-bug where the old {n} newline char stopped working
As of this commit, one can use the old newline character `{n}` or the new `\n` Closes #661
This commit is contained in:
parent
804a60f781
commit
92ac353b48
1 changed files with 5 additions and 5 deletions
|
@ -353,7 +353,7 @@ impl<'a> Help<'a> {
|
|||
let too_long = str_width(h) >= width;
|
||||
|
||||
debug!("Too long...");
|
||||
if too_long {
|
||||
if too_long || h.contains("{n}") {
|
||||
sdebugln!("Yes");
|
||||
help.push_str(h);
|
||||
debugln!("help: {}", help);
|
||||
|
@ -380,11 +380,11 @@ impl<'a> Help<'a> {
|
|||
help.push_str(h);
|
||||
&*help
|
||||
};
|
||||
if help.contains("{n}") {
|
||||
if let Some(part) = help.split("{n}").next() {
|
||||
if help.contains("\n") {
|
||||
if let Some(part) = help.split("\n").next() {
|
||||
try!(write!(self.writer, "{}", part));
|
||||
}
|
||||
for part in help.split("{n}").skip(1) {
|
||||
for part in help.split("\n").skip(1) {
|
||||
try!(write!(self.writer, "\n{}", part));
|
||||
}
|
||||
} else {
|
||||
|
@ -432,7 +432,7 @@ impl<'a> Help<'a> {
|
|||
}
|
||||
|
||||
debug!("Too long...");
|
||||
if too_long && spcs <= width {
|
||||
if too_long && spcs <= width || h.contains("{n}") {
|
||||
sdebugln!("Yes");
|
||||
help.push_str(h);
|
||||
help.push_str(&*spec_vals);
|
||||
|
|
Loading…
Reference in a new issue