summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/tree.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/apps/tree.c b/apps/tree.c
index b50dd5c..5a8618b 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -380,6 +380,21 @@ static int showdir(char *path, int start)
dirstart = start;
}
+ /* The cursor might point to an invalid line, for example if someone
+ deleted the last file in the dir */
+ if(filesindir)
+ {
+ while(start + dircursor >= filesindir)
+ {
+ if(start)
+ start--;
+ else
+ if(dircursor)
+ dircursor--;
+ }
+ dirstart = start;
+ }
+
#ifdef HAVE_LCD_CHARCELLS
lcd_stop_scroll();
lcd_double_height(false);
@@ -1119,6 +1134,7 @@ bool dirbrowse(char *root)
if (restore || reload_dir) {
/* restore display */
+
/* We need to adjust if the number of lines on screen have
changed because of a status bar change */
if(CURSOR_Y+LINE_Y+dircursor>tree_max_on_screen) {