From 876da97d1ccebf84b15a25df7a9e895bdf6a2fdd Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 7 Sep 2022 15:52:26 -0500 Subject: [PATCH] fix(help): Make next-line help less sensitive to tab changes --- src/output/help.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/output/help.rs b/src/output/help.rs index 9f1965ad..1319bc81 100644 --- a/src/output/help.rs +++ b/src/output/help.rs @@ -547,11 +547,13 @@ impl<'cmd, 'writer> Help<'cmd, 'writer> { // Is help on next line, if so then indent if next_line_help { debug!("Help::help: Next Line...{:?}", next_line_help); - self.none(format!("\n{}{}{}", TAB, TAB, TAB)); + self.none("\n"); + self.none(TAB); + self.none(NEXT_LINE_INDENT); } let trailing_indent = if next_line_help { - TAB_WIDTH * 3 + TAB.len() + NEXT_LINE_INDENT.len() } else if let Some(true) = arg.map(|a| a.is_positional()) { longest + TAB_WIDTH * 2 } else { @@ -560,7 +562,7 @@ impl<'cmd, 'writer> Help<'cmd, 'writer> { let trailing_indent = self.get_spaces(trailing_indent); let spaces = if next_line_help { - TAB_WIDTH * 3 + TAB.len() + NEXT_LINE_INDENT.len() } else { longest + TAB_WIDTH * 3 }; @@ -932,6 +934,8 @@ impl<'cmd, 'writer> Help<'cmd, 'writer> { } } +const NEXT_LINE_INDENT: &str = " "; + type ArgSortKey = fn(arg: &Arg) -> (usize, String); fn positional_sort_key(arg: &Arg) -> (usize, String) {