From 613c57c1aa6d3ac466e136f46cdfced46a24e565 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 20 Jul 2022 18:07:44 +0200 Subject: [PATCH] Fix screen scrolling when cursor is at bottom --- src/ui/chat/tree/layout.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ui/chat/tree/layout.rs b/src/ui/chat/tree/layout.rs index 6b3d128..4f6155f 100644 --- a/src/ui/chat/tree/layout.rs +++ b/src/ui/chat/tree/layout.rs @@ -48,7 +48,11 @@ impl> InnerTreeViewState { last_cursor_path: &Path, size: Size, ) -> i32 { - if let Some(block) = last_blocks.find(|b| cursor.matches_block(b)) { + if matches!(cursor, Cursor::Bottom) { + // Ensures that a Cursor::Bottom is always at the bottom of the + // screen. Will be scroll-clamped to the bottom later. + 0 + } else if let Some(block) = last_blocks.find(|b| cursor.matches_block(b)) { block.line } else if last_cursor_path < cursor_path { // If the cursor is bottom, the bottom marker needs to be located at