From ec10ac992a7bdb7dad485f9cb1b14e67fefdfd89 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Mon, 13 Mar 2023 20:12:13 +0100 Subject: [PATCH] cleanup --- src/editor.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index a5b1866..b1ea346 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -279,17 +279,10 @@ impl Editor { } fn scroll_to_cursor(&mut self) { - // while self.cursor.line < self.scroll { - // self.scroll -= 1; - // } - // while self.cursor.line > (self.scroll + terminal::size().unwrap().1 as usize - 2) { - // self.scroll += 1; - // } - self.scroll = self.scroll.min(self.cursor.line); let height = terminal::size().unwrap().1 as usize - 2; self.scroll = self .scroll - .max(self.scroll + self.cursor.line.saturating_sub(self.scroll + height)); + .clamp(self.cursor.line.saturating_sub(height), self.cursor.line); } fn move_home(&mut self) {