From 00101de4f4f3fe3de45a0e785147972d2eb91d50 Mon Sep 17 00:00:00 2001 From: d0k3 Date: Fri, 10 Jun 2016 14:23:37 +0200 Subject: [PATCH] Auto-adjust scroll after big delete operations --- source/godmode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/godmode.c b/source/godmode.c index cf69cae..3b35940 100644 --- a/source/godmode.c +++ b/source/godmode.c @@ -134,6 +134,8 @@ void DrawDirContents(DirStruct* contents, u32 cursor, u32* scroll) { if (*scroll > cursor) *scroll = cursor; else if (*scroll + lines <= cursor) *scroll = cursor - lines + 1; + if (*scroll + lines > contents->n_entries) + *scroll = (contents->n_entries > lines) ? contents->n_entries - lines : 0; for (u32 i = 0; pos_y < SCREEN_HEIGHT; i++) { char tempstr[str_width + 1];