Skip to content

Commit 01cae79

Browse files
committed
imp(Help Wrapping): makes some minor changes to when next line help is automatically used
1 parent 7e21b44 commit 01cae79

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/app/help.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,9 @@ impl<'a> Help<'a> {
313313
let nlh = self.next_line_help || arg.is_set(ArgSettings::NextLineHelp);
314314
let width = self.term_w;
315315
let taken = (longest + 12) + str_width(&*spec_vals);
316-
let force_next_line = !nlh && width >= taken && str_width(h) > (width - taken) &&
317-
(taken as f32 / width as f32) > 0.25;
316+
let force_next_line = !nlh && width >= taken &&
317+
(taken as f32 / width as f32) > 0.35 &&
318+
str_width(h) > (width - taken);
318319

319320
if arg.has_switch() {
320321
if !(nlh || force_next_line) {
@@ -402,8 +403,9 @@ impl<'a> Help<'a> {
402403

403404
// We calculate with longest+12 since if it's already NLH we don't care
404405
let taken = (longest + 12) + str_width(&*spec_vals);
405-
let force_next_line = !nlh && width >= taken && str_width(h) > (width - taken) &&
406-
(taken as f32 / width as f32) > 0.25;
406+
let force_next_line = !nlh && width >= taken &&
407+
(taken as f32 / width as f32) > 0.35 &&
408+
str_width(h) > (width - taken);
407409
debugln!("Force Next Line...{:?}", force_next_line);
408410
debugln!("Force Next Line math (help_len > (width - flags/opts/spcs))...{} > ({} - {})",
409411
str_width(h),
@@ -421,7 +423,7 @@ impl<'a> Help<'a> {
421423

422424
// Is help on next line, if so newline + 2x tab
423425
if nlh || force_next_line {
424-
try!(write!(self.writer, "\n{}{}", TAB, TAB));
426+
try!(write!(self.writer, "\n{}{}{}", TAB, TAB, TAB));
425427
}
426428

427429
debug!("Too long...");
@@ -463,7 +465,7 @@ impl<'a> Help<'a> {
463465
for part in help.split("{n}").skip(1) {
464466
try!(write!(self.writer, "\n"));
465467
if nlh || force_next_line {
466-
try!(write!(self.writer, "{}{}", TAB, TAB));
468+
try!(write!(self.writer, "{}{}{}", TAB, TAB, TAB));
467469
} else if arg.has_switch() {
468470
write_nspaces!(self.writer, longest + 12);
469471
} else {

0 commit comments

Comments
 (0)