diff --git a/src/files.c b/src/files.c
index 2b585116bad8ee2c8ba653f2406e7f7247297120..523e75dd1f0875fb49c59be02da46fb248217d86 100644
--- a/src/files.c
+++ b/src/files.c
@@ -2756,15 +2756,14 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t
  * position should be advanced.  refresh_func is the function we will
  * call to refresh the edit window. */
 char *input_tab(char *buf, bool allow_files, size_t *place,
-	bool *lastwastab, bool *listed)
+	bool *lastwastab, void (*refresh_func)(void))
 {
     size_t num_matches = 0, buf_len;
     char **matches = NULL;
+    bool listed = FALSE;
 
     assert(buf != NULL && place != NULL && *place <= strlen(buf) &&
-		lastwastab != NULL && listed != NULL);
-
-    *listed = FALSE;
+		lastwastab != NULL && refresh_func != NULL);
 
     /* If the word starts with `~' and there is no slash in the word,
      * then try completing this word as a username. */
@@ -2897,7 +2896,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
 	    }
 
 	    wnoutrefresh(edit);
-	    *listed = TRUE;
+	    listed = TRUE;
 	}
 
 	free(mzero);
@@ -2905,6 +2904,10 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
 
     free_chararray(matches, num_matches);
 
+    /* Refresh the edit window just in case a previous tab showed a list. */
+    if (!listed)
+	refresh_func();
+
     return buf;
 }
 #endif /* !DISABLE_TABCOMP */
diff --git a/src/prompt.c b/src/prompt.c
index e621bc63849b7b8611265d5f78b1612a2d401e84..53e1ad6487d73a9aa43395d1efdb8981a4af0413 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -529,7 +529,7 @@ void update_bar_if_needed(void)
 /* Get a string of input at the statusbar prompt. */
 functionptrtype get_prompt_string(int *actual, bool allow_tabs,
 #ifndef DISABLE_TABCOMP
-	bool allow_files, bool *listed,
+	bool allow_files,
 #endif
 	const char *curranswer,
 #ifndef DISABLE_HISTORIES
@@ -619,7 +619,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs,
 #endif
 	    if (allow_tabs)
 		answer = input_tab(answer, allow_files, &statusbar_x,
-				   &tabbed, listed);
+				   &tabbed, refresh_func);
 
 	    update_the_statusbar();
 	} else
@@ -735,9 +735,7 @@ int do_prompt(bool allow_tabs,
     va_list ap;
     int retval;
     functionptrtype func;
-#ifndef DISABLE_TABCOMP
-    bool listed = FALSE;
-#endif
+
     /* Save a possible current statusbar x position. */
     size_t was_statusbar_x = statusbar_x;
     size_t was_pww = statusbar_pww;
@@ -753,7 +751,7 @@ int do_prompt(bool allow_tabs,
 
     func = get_prompt_string(&retval, allow_tabs,
 #ifndef DISABLE_TABCOMP
-			allow_files, &listed,
+			allow_files,
 #endif
 	curranswer,
 #ifndef DISABLE_HISTORIES
@@ -785,13 +783,6 @@ int do_prompt(bool allow_tabs,
     fprintf(stderr, "answer = \"%s\"\n", answer);
 #endif
 
-#ifndef DISABLE_TABCOMP
-    /* If we've done tab completion, and a list of filename matches
-     * was printed in the edit window, clear them off. */
-    if (listed)
-	refresh_func();
-#endif
-
     return retval;
 }
 
diff --git a/src/proto.h b/src/proto.h
index 7985c76daa9716b1cddf1784a4505318a53f9d5c..5373476bbc3c02e4851ae4dbd9d6f79ef676873e 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -340,7 +340,7 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
 char **cwd_tab_completion(const char *buf, bool allow_files, size_t
 	*num_matches, size_t buf_len);
 char *input_tab(char *buf, bool allow_files, size_t *place,
-	bool *lastwastab, bool *listed);
+	bool *lastwastab, void (*refresh_func)(void));
 #endif
 const char *tail(const char *path);
 #ifndef DISABLE_HISTORIES
@@ -532,7 +532,7 @@ void update_the_statusbar(void);
 void update_bar_if_needed(void);
 functionptrtype get_prompt_string(int *value, bool allow_tabs,
 #ifndef DISABLE_TABCOMP
-	bool allow_files, bool *listed,
+	bool allow_files,
 #endif
 	const char *curranswer,
 #ifndef DISABLE_HISTORIES