From 420e9322eac301906ea87bb03a3a9304ebb5f846 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 5 Jun 2021 14:07:09 +0200 Subject: [PATCH 1/2] more: do not accidentically hide last line --- src/uu/more/src/more.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index 27829d57723..d37dd46f452 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -349,7 +349,7 @@ fn calc_range(mut upper_mark: u16, rows: u16, line_count: u16) -> (u16, u16) { let mut lower_mark = upper_mark.saturating_add(rows); if lower_mark >= line_count { - upper_mark = line_count.saturating_sub(rows); + upper_mark = line_count.saturating_sub(rows).saturating_add(1); lower_mark = line_count; } else { lower_mark = lower_mark.saturating_sub(1) From 2760efb01de4f135287ca3763c6e16f547e1f82e Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 5 Jun 2021 14:42:43 +0200 Subject: [PATCH 2/2] more: fix test --- src/uu/more/src/more.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index d37dd46f452..c1df9afa0e8 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -380,7 +380,7 @@ mod tests { fn test_calc_range() { assert_eq!((0, 24), calc_range(0, 25, 100)); assert_eq!((50, 74), calc_range(50, 25, 100)); - assert_eq!((75, 100), calc_range(85, 25, 100)); + assert_eq!((76, 100), calc_range(85, 25, 100)); } #[test] fn test_break_lines_long() {