Skip to content

Commit

Permalink
fix: include final character in line lenght
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mgeisler committed Jan 30, 2017
1 parent 72d7bf3 commit aff4ba1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ fn wrap_help(help: &mut String, longest_w: usize, avail_chars: usize) {
continue;
}
debugln!("Help::wrap_help:iter: Reached the end of the line and we're over...");
} else if str_width(&help[j..idx]) < avail_chars {
} else if str_width(&help[j..idx]) <= avail_chars {
debugln!("Help::wrap_help:iter: Space found with room...");
prev_space = idx;
continue;
Expand Down
7 changes: 3 additions & 4 deletions tests/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ OPTIONS:
latte, cappuccino, espresso), tea, and other
hot beverages. Some coffeehouses also serve
cold beverages such as iced coffee and iced
tea. Many cafés also serve some type of
food, such as light snacks, muffins, or
pastries.";
tea. Many cafés also serve some type of food,
such as light snacks, muffins, or pastries.";

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

0 comments on commit aff4ba1

Please sign in to comment.