---- a/menu.c
-+++ b/menu.c
-@@ -840,8 +840,12 @@ int menu_redraw (MUTTMENU *menu)
+Index: mutt/menu.c
+===================================================================
+--- mutt.orig/menu.c 2009-06-25 12:35:36.000000000 +0200
++++ mutt/menu.c 2009-06-25 12:36:19.000000000 +0200
+@@ -853,8 +853,17 @@
-+ if (menu->is_mailbox_list && last_position >= 0)
-+ menu->current = last_position;
++ if ( menu->max && menu->is_mailbox_list ) {
++ if ( last_position > (menu->max-1) ) {
++ last_position = -1;
++ } else if (last_position >= 0) {
++ menu->current = last_position;
++ }
++ }
---- a/browser.c
-+++ b/browser.c
-@@ -56,6 +56,7 @@ typedef struct folder_t
+Index: mutt/browser.c
+===================================================================
+--- mutt.orig/browser.c 2009-06-25 12:35:37.000000000 +0200
++++ mutt/browser.c 2009-06-25 12:36:19.000000000 +0200
+@@ -55,6 +55,7 @@
{
+ menu->is_mailbox_list = 0;
strfcpy (path, LastDir, sizeof (path));
{
+ menu->is_mailbox_list = 0;
strfcpy (path, LastDir, sizeof (path));
-- if (state->imap_browse && option (OPTIMAPLSUB))
-- snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"),
-- path, NONULL (Mask.pattern));
-- else
-+ if (state->imap_browse && option (OPTIMAPLSUB))
-+ snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"),
-+ path, NONULL (Mask.pattern));
-+ else
+@@ -530,8 +535,22 @@
+ path, NONULL (Mask.pattern));
+ else
#endif
- snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
- path, NONULL(Mask.pattern));
#endif
- snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
- path, NONULL(Mask.pattern));
-+ {
-+ char *p = strrchr (OldLastDir, '/');
-+ if (p && p - OldLastDir == mutt_strlen (LastDir) &&
-+ mutt_strncmp (LastDir, OldLastDir, p - OldLastDir) == 0)
-+ {
-+ /* If we get here, it means that LastDir is the parent directory of
-+ * OldLastDir. I.e., we're returning from a subdirectory, and we want
-+ * to position the cursor on the directory we're returning from. */
-+ int i;
-+ for (i = 0; i < state->entrymax; i++)
-+ if (mutt_strcmp (state->entry[i].name, p + 1) == 0)
-+ menu->current = i;
-+ }
-+ snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
-+ path, NONULL(Mask.pattern));
-+ }
-+
++ {
++ char *p = strrchr (OldLastDir, '/');
++ if (p && p - OldLastDir == mutt_strlen (LastDir) &&
++ mutt_strncmp (LastDir, OldLastDir, p - OldLastDir) == 0)
++ {
++ /* If we get here, it means that LastDir is the parent directory of
++ * OldLastDir. I.e., we're returning from a subdirectory, and we want
++ * to position the cursor on the directory we're returning from. */
++ int i;
++ for (i = 0; i < state->entrymax; i++)
++ if (mutt_strcmp (state->entry[i].name, p + 1) == 0)
++ menu->current = i;
++ }
++ snprintf (title, titlelen, _("Directory [%s], File mask: %s"),
++ path, NONULL(Mask.pattern));
++ }
/* save the old directory */
strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
/* save the old directory */
strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
---- a/mutt_menu.h
-+++ b/mutt_menu.h
-@@ -49,6 +49,7 @@ typedef struct menu_t
+Index: mutt/mutt_menu.h
+===================================================================
+--- mutt.orig/mutt_menu.h 2009-06-25 12:35:44.000000000 +0200
++++ mutt/mutt_menu.h 2009-06-25 12:36:19.000000000 +0200
+@@ -49,6 +49,7 @@
int offset; /* which screen row to start the index */
int pagelen; /* number of entries per screen */
int tagprefix;
int offset; /* which screen row to start the index */
int pagelen; /* number of entries per screen */
int tagprefix;
/* Setting dialog != NULL overrides normal menu behaviour.
* In dialog mode menubar is hidden and prompt keys are checked before
/* Setting dialog != NULL overrides normal menu behaviour.
* In dialog mode menubar is hidden and prompt keys are checked before