Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/uu/more/src/more.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl Options {
) {
// We add 1 to the number of lines to display because the last line
// is used for the banner
(Some(n), _) | (None, Some(n)) if n > 0 => Some(n + 1),
(Some(n), _) | (None, Some(n)) if n > 0 => Some(n.saturating_add(1)),
_ => None, // Use terminal height
};
let from_line = match matches.get_one::<usize>(options::FROM_LINE).copied() {
Expand Down Expand Up @@ -1137,6 +1137,14 @@ mod tests {
assert!(!stdout.contains("2\n"));
}

#[test]
fn test_lines_option_max_u16() {
// The +1 for the banner line used to overflow when -n is u16::MAX.
let matches = uu_app().get_matches_from(vec!["more", "-n", "65535"]);
let options = Options::from(&matches);
assert_eq!(options.lines, Some(u16::MAX));
}

#[test]
fn test_from_line_option() {
let content = (0..5).map(|i| i.to_string() + "\n").collect::<String>();
Expand Down
Loading