From 3cd42527ecd4befca566ea1f623c8f00bb321fe9 Mon Sep 17 00:00:00 2001 From: dal Date: Thu, 10 Apr 2025 11:21:00 -0600 Subject: [PATCH] string formatting --- cli/cli/src/commands/chat/ui.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cli/cli/src/commands/chat/ui.rs b/cli/cli/src/commands/chat/ui.rs index d4c01f6ed..552341f47 100644 --- a/cli/cli/src/commands/chat/ui.rs +++ b/cli/cli/src/commands/chat/ui.rs @@ -106,13 +106,23 @@ fn render_messages(frame: &mut Frame, app: &AppState, area: Rect) { .add_modifier(Modifier::BOLD), ); - let mut lines_for_msg = vec![prefix]; if let Some(c) = content { - lines_for_msg.push(Span::styled(c, Style::default().fg(Color::White))); + let lines: Vec<&str> = c.split('\n').collect(); + for (i, line_content) in lines.iter().enumerate() { + let line_span = Span::styled(*line_content, Style::default().fg(Color::White)); + if i == 0 { + message_lines.push(Line::from(vec![prefix.clone(), line_span])); + } else { + message_lines.push(Line::from(vec![ + Span::raw(" "), + line_span, + ])); + } + } + } else { + message_lines.push(Line::from(prefix)); } - message_lines.push(Line::from(lines_for_msg)); - if !is_in_progress { message_lines.push(Line::from("")); }