From 576eaaf9901a06f73ae9ea969b69949825c02e7f Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 31 Aug 2024 13:33:45 +0100 Subject: [PATCH] refactor(tui): introduce LogLine to wrap log formatting --- crates/cli/src/tui/components/history.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/cli/src/tui/components/history.rs b/crates/cli/src/tui/components/history.rs index 6785e2a..ba63ce0 100644 --- a/crates/cli/src/tui/components/history.rs +++ b/crates/cli/src/tui/components/history.rs @@ -1,5 +1,5 @@ -use git_next_core::git::graph::Log; // +use git_next_core::git::graph::Log; use ratatui::{ text::{Line, Text}, widgets::{Paragraph, Widget}, @@ -23,10 +23,24 @@ impl<'a> Widget for CommitLog<'a> { Paragraph::new(Text::from( self.log .iter() - .map(ToString::to_string) + .map(LogLine::new) .map(Line::from) .collect::>(), )) .render(area, buf); } } + +struct LogLine { + raw: String, +} +impl LogLine { + fn new(raw: impl Into) -> Self { + Self { raw: raw.into() } + } +} +impl From for Line<'_> { + fn from(value: LogLine) -> Self { + Line::from(value.raw) + } +}