From 2d1a9f6709c631319f379fcf4a03c7f3aeba7112 Mon Sep 17 00:00:00 2001 From: Ideflop <94184575+Ideflop@users.noreply.github.com> Date: Sat, 20 May 2023 08:56:50 +0200 Subject: [PATCH] fix behavior of -c and -p commands --- src/uu/more/src/more.rs | 11 ++++++++--- tests/by-util/test_more.rs | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index 2b6bde9da..08e6fdd70 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -333,9 +333,14 @@ fn more( _ => continue, } - if options.clean_print { - execute!(std::io::stdout(), Clear(ClearType::Purge), MoveTo(0, 0)).unwrap(); - } else if options.print_over { + if options.print_over { + execute!( + std::io::stdout(), + MoveTo(0, 0), + Clear(ClearType::FromCursorDown) + ) + .unwrap(); + } else if options.clean_print { execute!(std::io::stdout(), Clear(ClearType::All), MoveTo(0, 0)).unwrap(); } pager.draw(stdout, wrong_key); diff --git a/tests/by-util/test_more.rs b/tests/by-util/test_more.rs index 80d3c3da4..bffa88cab 100644 --- a/tests/by-util/test_more.rs +++ b/tests/by-util/test_more.rs @@ -13,11 +13,11 @@ fn test_more_no_arg() { #[test] fn test_valid_arg() { if std::io::stdout().is_terminal() { - new_ucmd!().arg("-c").succeeds().code_is(0); - new_ucmd!().arg("--print-over").succeeds().code_is(0); + new_ucmd!().arg("-c").succeeds(); + new_ucmd!().arg("--print-over").succeeds(); - new_ucmd!().arg("-p").succeeds().code_is(0); - new_ucmd!().arg("--clean-print").succeeds().code_is(0); + new_ucmd!().arg("-p").succeeds(); + new_ucmd!().arg("--clean-print").succeeds(); } else { } }