From 3281b9077fddb7d40278c0479b27e1fb5f2c9c0f Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 24 Nov 2025 10:43:20 +0100 Subject: [PATCH] agent: Fix utf8 panic in outline (#43141) Fixes ZED-3F3 Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/agent/src/outline.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/agent/src/outline.rs b/crates/agent/src/outline.rs index 0de035c34bf285d41ff20676f037abf2464213a1..40a84bc28b4402d8251e164a423a2309127c50ce 100644 --- a/crates/agent/src/outline.rs +++ b/crates/agent/src/outline.rs @@ -48,7 +48,7 @@ pub async fn get_buffer_content_or_outline( if outline_items.is_empty() { let text = buffer.read_with(cx, |buffer, _| { let snapshot = buffer.snapshot(); - let len = snapshot.len().min(1024); + let len = snapshot.len().min(snapshot.as_rope().floor_char_boundary(1024)); let content = snapshot.text_for_range(0..len).collect::(); if let Some(path) = path { format!("# First 1KB of {path} (file too large to show full content, and no outline available)\n\n{content}") @@ -178,7 +178,7 @@ mod tests { let fs = FakeFs::new(cx.executor()); let project = Project::test(fs, [], cx).await; - let content = "A".repeat(100 * 1024); // 100KB + let content = "⚡".repeat(100 * 1024); // 100KB let content_len = content.len(); let buffer = project .update(cx, |project, cx| project.create_buffer(true, cx)) @@ -194,7 +194,7 @@ mod tests { // Should contain some of the actual file content assert!( - result.text.contains("AAAAAAAAAA"), + result.text.contains("⚡⚡⚡⚡⚡⚡⚡"), "Result did not contain content subset" );