From 54b056ba1c4c5bc33f56f1c874770a53ea81ca94 Mon Sep 17 00:00:00 2001 From: Joscha Date: Fri, 24 Jun 2022 00:56:36 +0200 Subject: [PATCH] Fix cursor scrolling When scrolling up, the cursor would get stuck at certain screen heights, i.e. the screen would scroll and the cursor would stay at the same line. When scrolling down, the screen would sometimes jump by one line. This weird behaviour was caused by an incorrect conversion between screen lines and cursor proportion. --- src/chat/tree/util.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chat/tree/util.rs b/src/chat/tree/util.rs index 6fa1f59..c5dd241 100644 --- a/src/chat/tree/util.rs +++ b/src/chat/tree/util.rs @@ -44,7 +44,7 @@ pub fn after_nick(frame: &mut Frame, indent: usize, nick: &str) -> i32 { } pub fn proportion_to_line(height: u16, proportion: f32) -> i32 { - ((height - 1) as f32 * proportion).ceil() as i32 + ((height - 1) as f32 * proportion).round() as i32 } pub fn line_to_proportion(height: u16, line: i32) -> f32 {