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.

repl: Ensure that the output's computed line height is at least 1 (#14877)

Kyle Kelley781633fb1ad0
diff --git a/crates/repl/src/outputs.rs b/crates/repl/src/outputs.rs
index 17dc8b0180a..2d61fd98645 100644
--- a/crates/repl/src/outputs.rs
+++ b/crates/repl/src/outputs.rs
@@ -553,9 +553,10 @@ impl LineHeight for ExecutionView {
self.outputs
.iter()
.map(|output| output.num_lines(cx))
- .fold(0, |acc, additional_height| {
+ .fold(0_u8, |acc, additional_height| {
acc.saturating_add(additional_height)
})
+ .max(1)
}
}
diff --git a/crates/repl/src/stdio.rs b/crates/repl/src/stdio.rs
index 38a154e289b..1500c8bc5f3 100644
--- a/crates/repl/src/stdio.rs
+++ b/crates/repl/src/stdio.rs
@@ -88,7 +88,7 @@ impl TerminalOutput {
impl LineHeight for TerminalOutput {
fn num_lines(&self, _cx: &mut WindowContext) -> u8 {
- self.handler.buffer.lines().count() as u8
+ self.handler.buffer.lines().count().max(1) as u8
}
}