From ebe77d86e5c1a44752263ef0773c4b62af239eef Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 23 Jan 2024 11:28:27 +0100 Subject: [PATCH] fix: fix off by one debugger draw --- crates/debugger/src/tui/draw.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/debugger/src/tui/draw.rs b/crates/debugger/src/tui/draw.rs index dd313750259b..8394d3a2e4b6 100644 --- a/crates/debugger/src/tui/draw.rs +++ b/crates/debugger/src/tui/draw.rs @@ -237,8 +237,9 @@ impl DebuggerContext<'_> { // adjust what text we show of the source code let (start_line, end_line) = if needed_highlight > height { - // highlighted section is more lines than we have avail - (before.len(), before.len() + needed_highlight) + // highlighted section is more lines than we have available + let start_line = before.len().saturating_sub(1); + (start_line, before.len() + needed_highlight) } else if height > num_lines { // we can fit entire source (0, num_lines)