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

This commit is contained in:
Kyle Kelley 2024-07-20 15:59:28 -07:00 committed by GitHub
parent 6dfb0a4a70
commit 781633fb1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View File

@ -553,9 +553,10 @@ impl LineHeight for ExecutionView {
self.outputs self.outputs
.iter() .iter()
.map(|output| output.num_lines(cx)) .map(|output| output.num_lines(cx))
.fold(0, |acc, additional_height| { .fold(0_u8, |acc, additional_height| {
acc.saturating_add(additional_height) acc.saturating_add(additional_height)
}) })
.max(1)
} }
} }

View File

@ -88,7 +88,7 @@ impl TerminalOutput {
impl LineHeight for TerminalOutput { impl LineHeight for TerminalOutput {
fn num_lines(&self, _cx: &mut WindowContext) -> u8 { fn num_lines(&self, _cx: &mut WindowContext) -> u8 {
self.handler.buffer.lines().count() as u8 self.handler.buffer.lines().count().max(1) as u8
} }
} }