diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 0931b40c8e..bc1f0e71f2 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -2139,7 +2139,7 @@ pub enum LogContentFormat { impl LogContentFormat { pub fn new(ui: &Ui, settings: &UserSettings) -> Result { if settings.config().get_bool("ui.log-word-wrap")? { - let term_width = usize::from(ui.term_width().unwrap_or(80)); + let term_width = ui.term_width(); Ok(LogContentFormat::Wrap { term_width }) } else { Ok(LogContentFormat::NoWrap) diff --git a/cli/src/diff_util.rs b/cli/src/diff_util.rs index 26a4ea6505..d58fb970f0 100644 --- a/cli/src/diff_util.rs +++ b/cli/src/diff_util.rs @@ -257,7 +257,7 @@ impl<'a> DiffRenderer<'a> { DiffFormat::Stat => { let tree_diff = from_tree.diff_stream(to_tree, matcher); // TODO: In graph log, graph width should be subtracted - let width = usize::from(ui.term_width().unwrap_or(80)); + let width = ui.term_width(); show_diff_stat(formatter, store, tree_diff, path_converter, width)?; } DiffFormat::Types => { diff --git a/cli/src/ui.rs b/cli/src/ui.rs index 38dcaef571..21945db687 100644 --- a/cli/src/ui.rs +++ b/cli/src/ui.rs @@ -578,8 +578,8 @@ impl Ui { rpassword::prompt_password(format!("{prompt}: ")) } - pub fn term_width(&self) -> Option { - term_width() + pub fn term_width(&self) -> usize { + term_width().unwrap_or(80).into() } }