Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

format_cell bug fix

henryb4b15c9d9c5c
diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rs
index 94ff44d7a..592a2851f 100644
--- a/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/screenpipe-server/src/bin/screenpipe-server.rs
@@ -483,7 +483,15 @@ async fn main() -> anyhow::Result<()> {
// Function to truncate and pad strings
fn format_cell(s: &str, width: usize) -> String {
if s.len() > width {
- format!("{}...", &s[..width - 3])
+ let mut max_pos = 0;
+ for (i, c) in s.char_indices() {
+ if i + c.len_utf8() > width - 3 {
+ break;
+ }
+ max_pos = i + c.len_utf8();
+ }
+
+ format!("{}...", &s[..max_pos])
} else {
format!("{:<width$}", s, width = width)
}