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

Kyle Kelley created

Change summary

crates/repl/src/outputs.rs | 3 ++-
crates/repl/src/stdio.rs   | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)

Detailed changes

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)
     }
 }
 

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
     }
 }