From 9a5e615331ac4734217c7a3c2a2674cfc2c75538 Mon Sep 17 00:00:00 2001 From: sorgelig Date: Mon, 17 Feb 2020 03:52:23 +0800 Subject: [PATCH] Fix positioning in file browser. --- file_io.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/file_io.cpp b/file_io.cpp index 86c78c8..8e712b1 100644 --- a/file_io.cpp +++ b/file_io.cpp @@ -1423,7 +1423,7 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons if (!strcmp(file_name, DirItem[i].de.d_name)) { iSelectedEntry = i; - if (iSelectedEntry + (OsdGetSize() / 2) - 1 >= flist_nDirEntries()) iFirstEntry = flist_nDirEntries() - OsdGetSize(); + if (iSelectedEntry + (OsdGetSize() / 2) >= flist_nDirEntries()) iFirstEntry = flist_nDirEntries() - OsdGetSize(); else iFirstEntry = iSelectedEntry - (OsdGetSize() / 2) + 1; if (iFirstEntry < 0) iFirstEntry = 0; break; @@ -1512,7 +1512,7 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons if((DirItem[i].de.d_type == DT_DIR) && !strcmp(DirItem[i].altname, extension)) { iSelectedEntry = i; - if (iSelectedEntry + (OsdGetSize() / 2) - 1 >= flist_nDirEntries()) iFirstEntry = flist_nDirEntries() - OsdGetSize(); + if (iSelectedEntry + (OsdGetSize() / 2) >= flist_nDirEntries()) iFirstEntry = flist_nDirEntries() - OsdGetSize(); else iFirstEntry = iSelectedEntry - (OsdGetSize() / 2) + 1; if (iFirstEntry < 0) iFirstEntry = 0; break; @@ -1551,7 +1551,7 @@ int ScanDirectory(char* path, int mode, const char *extension, int options, cons { iSelectedEntry = found; if (iSelectedEntry + (OsdGetSize() / 2) >= flist_nDirEntries()) iFirstEntry = flist_nDirEntries() - OsdGetSize(); - else iFirstEntry = iSelectedEntry - (OsdGetSize()/2) + 1; + else iFirstEntry = iSelectedEntry - (OsdGetSize()/2) + 1; if (iFirstEntry < 0) iFirstEntry = 0; } }