Skip to content

Commit 7c085aa

Browse files
DOsingaCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 1d2523e commit 7c085aa

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

crates/goose-cli/src/session/output.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ pub fn render_message(message: &Message, debug: bool) {
276276

277277
/// Render a streaming message, using a buffer to accumulate text content
278278
/// and only render when markdown constructs are complete.
279-
/// Returns true if the message contained text content (for tracking purposes).
279+
280280
pub fn render_message_streaming(message: &Message, buffer: &mut MarkdownBuffer, debug: bool) {
281281
let theme = get_theme();
282282

@@ -906,8 +906,13 @@ fn extract_markdown_table(content: &str) -> Option<(String, Vec<&str>, &str)> {
906906
""
907907
} else {
908908
let table_end_line = lines[end];
909-
let table_end_pos = content.find(table_end_line).unwrap() + table_end_line.len();
910-
content.get(table_end_pos + 1..).unwrap_or("")
909+
let content_ptr = content.as_ptr() as usize;
910+
let line_ptr = table_end_line.as_ptr() as usize;
911+
let table_end_pos = line_ptr.saturating_sub(content_ptr) + table_end_line.len();
912+
content
913+
.get(table_end_pos..)
914+
.and_then(|s| s.strip_prefix('\n'))
915+
.unwrap_or("")
911916
};
912917

913918
Some((before, table, after))

0 commit comments

Comments
 (0)