From 781633fb1ad02cb8ac7f36bf0e9af4a56a49c4e5 Mon Sep 17 00:00:00 2001 From: Kyle Kelley Date: Sat, 20 Jul 2024 15:59:28 -0700 Subject: [PATCH] repl: Ensure that the output's computed line height is at least 1 (#14877) --- crates/repl/src/outputs.rs | 3 ++- crates/repl/src/stdio.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/repl/src/outputs.rs b/crates/repl/src/outputs.rs index 17dc8b0180..2d61fd9864 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 38a154e289..1500c8bc5f 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 } }