From 3b139c962f45e22617a2fdb29ce1aa2ed53da634 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 29 Jun 2016 21:22:38 +0200 Subject: [PATCH 2/2] browser: move stuff to the end of the loop --- src/browser.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/browser.c b/src/browser.c index 5fc0e6e..63feb2d 100644 --- a/src/browser.c +++ b/src/browser.c @@ -91,9 +91,6 @@ char *do_browser(char *path) present_name = mallocstrcpy(present_name, filelist[selected]); } - /* Start with no key pressed. */ - kbinput = ERR; - assert(path != NULL && path[strlen(path) - 1] == '/'); if (dir != NULL) { @@ -131,30 +128,15 @@ char *do_browser(char *path) bottombars(MBROWSER); -#ifndef NANO_TINY - /* If the window resized, also refresh the file list. */ - if (kbinput == KEY_WINCH) { - /* Remember the selected file, to be able to reselect it. */ - present_name = strdup(filelist[selected]); - /* Reread the contents of the current directory. */ - newpath = strdup(present_path); - goto read_directory_contents; - } -#endif - /* Display (or redisplay) the file list if we don't have a key yet, - * or the list has changed, or the selected file has changed. */ - if (kbinput == ERR || old_selected != selected) + /* Display (or redisplay) the file list if the list itself or + * the selected file has changed. */ + if (old_selected != selected) browser_refresh(); old_selected = selected; kbinput = get_kbinput(edit); -#ifndef NANO_TINY - if (kbinput == KEY_WINCH) - continue; -#endif - #ifndef DISABLE_MOUSE if (kbinput == KEY_MOUSE) { int mouse_x, mouse_y; @@ -341,8 +323,23 @@ char *do_browser(char *path) } else if (func == do_exit) { /* Exit from the file browser. */ break; +#ifndef NANO_TINY + } else if (kbinput == KEY_WINCH) { + ; +#endif } else unbound_key(kbinput); + +#ifndef NANO_TINY + /* If the window resized, refresh the file list. */ + if (kbinput == KEY_WINCH) { + /* Remember the selected file, to be able to reselect it. */ + present_name = strdup(filelist[selected]); + /* Reread the contents of the current directory. */ + newpath = strdup(present_path); + goto read_directory_contents; + } +#endif } titlebar(NULL); -- 2.8.4