diff --git a/cli/src/ui.rs b/cli/src/ui.rs index 21945db687a..060f0f8bfe7 100644 --- a/cli/src/ui.rs +++ b/cli/src/ui.rs @@ -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; @@ -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(); }), } }