Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix truncation of bash output (#28374)

Antonio Scandurrad0632a533232
diff --git a/crates/assistant_tools/src/bash_tool.rs b/crates/assistant_tools/src/bash_tool.rs
index d0b6b885d66..23cbe3ca299 100644
--- a/crates/assistant_tools/src/bash_tool.rs
+++ b/crates/assistant_tools/src/bash_tool.rs
@@ -156,7 +156,21 @@ impl Tool for BashTool {
// Read one more byte to determine whether the output was truncated
let mut buffer = vec![0; LIMIT + 1];
- let bytes_read = reader.read(&mut buffer).await?;
+ let mut bytes_read = 0;
+
+ // Read until we reach the limit
+ loop {
+ let read = reader.read(&mut buffer).await?;
+ if read == 0 {
+ break;
+ }
+
+ bytes_read += read;
+ if bytes_read > LIMIT {
+ bytes_read = LIMIT + 1;
+ break;
+ }
+ }
// Repeatedly fill the output reader's buffer without copying it.
loop {