From 781655c41bdf0429fcbe685d770b10e41577fef6 Mon Sep 17 00:00:00 2001 From: Joscha Date: Mon, 1 Aug 2022 22:53:28 +0200 Subject: [PATCH] Fix initial scroll at bottom not moving screen When pressing ctrl+y while cursor = Cursor::Bottom, the screen would not scroll. Instead, the cursor would only jump to the lowest message on the screen. This was caused because the blocks were re-layouted after scrolling, starting from the Cursor::Bottom, thus resetting the scroll to the bottom of the screen. --- src/ui/chat/tree/layout.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ui/chat/tree/layout.rs b/src/ui/chat/tree/layout.rs index d8ddb37..dd2dacd 100644 --- a/src/ui/chat/tree/layout.rs +++ b/src/ui/chat/tree/layout.rs @@ -114,13 +114,17 @@ impl> InnerTreeViewState { blocks.blocks_mut().push_back(block); } - // Editor or pseudomessage - if let Cursor::Editor { parent: None, .. } | Cursor::Pseudo { parent: None, .. } = - self.cursor - { - // TODO Render proper editor or pseudocursor - let block = Block::new(frame, BlockId::Cursor, Text::new("TODO")); - blocks.blocks_mut().push_back(block); + match self.cursor { + Cursor::Bottom => { + let block = Block::new(frame, BlockId::Cursor, Empty); + blocks.blocks_mut().push_back(block); + } + Cursor::Editor { parent: None, .. } | Cursor::Pseudo { parent: None, .. } => { + // TODO Render proper editor or pseudocursor + let block = Block::new(frame, BlockId::Cursor, Text::new("TODO")); + blocks.blocks_mut().push_back(block); + } + _ => {} } blocks