Skip to content

Commit aff4ba1

Browse files
committed
fix: include final character in line lenght
Before, wrapping the help text at, say, 80 characters really meant that every line could be at most 79 characters wide. Lines can now be up to and including avail_chars columns wide. If needed, a desired margin or padding can be subtracted from the avail_chars argument at a later point.
1 parent 72d7bf3 commit aff4ba1

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/app/help.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ fn wrap_help(help: &mut String, longest_w: usize, avail_chars: usize) {
948948
continue;
949949
}
950950
debugln!("Help::wrap_help:iter: Reached the end of the line and we're over...");
951-
} else if str_width(&help[j..idx]) < avail_chars {
951+
} else if str_width(&help[j..idx]) <= avail_chars {
952952
debugln!("Help::wrap_help:iter: Space found with room...");
953953
prev_space = idx;
954954
continue;

tests/help.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@ OPTIONS:
113113
latte, cappuccino, espresso), tea, and other
114114
hot beverages. Some coffeehouses also serve
115115
cold beverages such as iced coffee and iced
116-
tea. Many cafés also serve some type of
117-
food, such as light snacks, muffins, or
118-
pastries.";
116+
tea. Many cafés also serve some type of food,
117+
such as light snacks, muffins, or pastries.";
119118

120119
static ISSUE_626_PANIC: &'static str = "ctest 0.1
121120
@@ -514,4 +513,4 @@ fn issue_777_wrap_all_things() {
514513
.about("Show how the about text is not wrapped")
515514
.set_term_width(35);
516515
assert!(test::compare_output(app, "ctest --help", ISSUE_777, false));
517-
}
516+
}

0 commit comments

Comments
 (0)