fix behavior of -c and -p commands

This commit is contained in:
Ideflop 2023-05-20 08:56:50 +02:00
parent 1a12ffaa79
commit 2d1a9f6709
2 changed files with 12 additions and 7 deletions

View file

@ -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);

View file

@ -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 {
}
}