Skip to content

Commit

Permalink
built-in pager: write a message to the user before panicking if pager…
Browse files Browse the repository at this point in the history
… doesn't start

This will hopefully improve the experience of users who encounter #4182.

Unfortunately, this is the most I can think of doing in the short term
to address the problem. See the linked issue for more details.
  • Loading branch information
ilyagr committed Aug 2, 2024
1 parent 5b22594 commit feae28c
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion cli/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::str::FromStr;
use std::thread::JoinHandle;
use std::{env, fmt, io, mem};

use indoc::indoc;
use minus::Pager as MinusPager;
use tracing::instrument;

Expand Down Expand Up @@ -87,7 +88,32 @@ impl BuiltinPager {
pager,
dynamic_pager_thread: std::thread::spawn(move || {
// This thread handles the actual paging.
minus::dynamic_paging(pager_handle).unwrap();
// TODO(#4182): handle error better
minus::dynamic_paging(pager_handle)
.inspect_err(|err| {
eprintln!("\n");
if let minus::error::MinusError::Setup(
minus::error::SetupError::InvalidTerminal,
) = err
{
eprintln!(indoc! {r#"
jj ERROR: jj's builtin pager is incompatible with this terminal
This is known to happen with `mintty`, the default Git Bash terminal on Windows.
See also https://github.com/martinvonz/jj/issues/4182.
POSSIBLE WORKAROUNDS:
- Use `jj --no-pager`
- Use a different terminal (e.g. Windows Terminal or the Command Prompt)
- Configure a different pager, see https://martinvonz.github.io/jj/latest/windows/#pagination for Git Bash on Windows
- Use `winpty jj ...` on Windows."#
})
} else {
eprintln!("jj ERROR: built-in pager failed to start, will panic.")
}
eprintln!();
})
.unwrap();
}),
}
}
Expand Down

0 comments on commit feae28c

Please sign in to comment.