Skip to content

Commit f220c39

Browse files
fix(cli): Stream REPL output as it arrives instead of buffering.
1 parent 8d71762 commit f220c39

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

cli/src/engine.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,19 @@ impl Session {
7878
let expr = format!("__edgeRun({literal})");
7979
self.tab.evaluate(&expr, false).map_err(|e| anyhow!("starting eval: {e}"))?;
8080

81-
let mut all: Vec<String> = Vec::new();
82-
let outcome = drain(&self.tab, &mut |line| all.push(line.to_string()))?;
83-
for line in all.iter().skip(self.history_lines) {
84-
on_line(line);
85-
}
81+
// Stream lines as they arrive; suppress the first `history_lines` (replayed history, already shown in prior evals) with a counter instead of buffering the whole run.
82+
let skip = self.history_lines;
83+
let mut seen = 0usize;
84+
let outcome = drain(&self.tab, &mut |line| {
85+
if seen >= skip {
86+
on_line(line);
87+
}
88+
seen += 1;
89+
})?;
8690
if outcome.err.is_none() {
8791
if !self.history.is_empty() { self.history.push('\n'); }
8892
self.history.push_str(src);
89-
self.history_lines = all.len();
93+
self.history_lines = seen;
9094
}
9195
Ok(outcome)
9296
}

0 commit comments

Comments
 (0)