titlebar(path);
while (!abort) {
- size_t fileline;
+ size_t fileline = (width != 0) ? selected / width : selected;
/* The line number the selected file is on. */
size_t old_selected = selected;
/* The selected file we had before the current selected
prev_dir = NULL;
}
- /* Calculate the line number we're on now, so that we don't
- * divide by zero. */
- fileline = selected;
- if (width != 0)
- fileline /= width;
-
switch (kbinput) {
#ifndef DISABLE_MOUSE
case KEY_MOUSE:
case NANO_NEXTPAGE_KEY:
selected += (editwinrows - fileline % editwinrows) *
width;
- if (selected >= filelist_len)
+ if (selected > filelist_len - 1)
selected = filelist_len - 1;
break;
case NANO_FIRSTFILE_ALTKEY: