On Thu, Jul 07, 2016 at 09:44:05AM -0700, Kevin J. McCarthy wrote:
> I'm also thinking about making a small change in
> mutt_sb_notify_mailbox() for the "created" case.  Right now we set
> HilIndex if it was unset, but I'm thinking of removing that and letting
> prepare_sidebar() set it instead (to help prevent the case where
> HilIndex points at a hidden mailbox that then becomes visible).  Do you
> see a problem with that?

Here's something more concrete to test.

The patch:
(1) removes setting HilIndex during mutt_sb_notify_mailbox()
(2) removes forcing the HilIndex entry visible in
    update_entries_visibility()
(3) tries to reset HilIndex in prepare_sidebar() if the current entry
    is hidden.

Obviously I haven't test this a great deal yet either, but I'll play
with it a few days and would appreciate if you would include it in your
testing this weekend.

Thanks!

-- 
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA
# HG changeset patch
# User Kevin McCarthy <ke...@8t8.us>
# Date 1467921000 25200
#      Thu Jul 07 12:50:00 2016 -0700
# Node ID ffd1db1d7db4b3ff06f615b59936150b81daf6c0
# Parent  03d7909338e81be5370e4610e55de4abdb9b4859
Change sidebar highlighted mailbox behavior.

Delay selecting the highlighted mailbox until prepare_mailbox(), to
avoid a hidden mailbox being selected during the Buffy list population
(in mutt_sb_notify_mailbox()).

Change update_entries_visibility() to not automatically make the
highlighted mailbox visible.

Change prepare_sidebar() to (re)set the highlighted mailbox when the
current highlighted mailbox is hidden.

diff --git a/sidebar.c b/sidebar.c
--- a/sidebar.c
+++ b/sidebar.c
@@ -298,17 +298,17 @@
     sbe = Entries[i];
 
     sbe->is_hidden = 0;
 
     if (!new_only)
       continue;
 
     if ((i == OpnIndex) || (sbe->buffy->msg_unread  > 0) || sbe->buffy->new ||
-        (i == HilIndex) || (sbe->buffy->msg_flagged > 0))
+        (sbe->buffy->msg_flagged > 0))
       continue;
 
     if (Context && (mutt_strcmp (sbe->buffy->realpath, Context->realpath) == 
0))
       /* Spool directory */
       continue;
 
     if (mutt_find_list (SidebarWhitelist, sbe->buffy->path))
       /* Explicitly asked to be visible */
@@ -405,17 +405,18 @@
   for (i = 0; i < EntryCount; i++)
   {
     if (opn_entry == Entries[i])
       OpnIndex = i;
     if (hil_entry == Entries[i])
       HilIndex = i;
   }
 
-  if ((HilIndex < 0) || (SidebarSortMethod != PreviousSort))
+  if ((HilIndex < 0) || Entries[HilIndex]->is_hidden ||
+      (SidebarSortMethod != PreviousSort))
   {
     if (OpnIndex >= 0)
       HilIndex = OpnIndex;
     else
     {
       HilIndex = 0;
       if (Entries[HilIndex]->is_hidden)
         select_next ();
@@ -1003,18 +1004,16 @@
       EntryLen += 10;
       safe_realloc (&Entries, EntryLen * sizeof (SBENTRY *));
     }
     Entries[EntryCount] = safe_calloc (1, sizeof(SBENTRY));
     Entries[EntryCount]->buffy = b;
 
     if (TopIndex < 0)
       TopIndex = EntryCount;
-    if (HilIndex < 0)
-      HilIndex = EntryCount;
     if (BotIndex < 0)
       BotIndex = EntryCount;
     if ((OpnIndex < 0) && Context &&
         (mutt_strcmp (b->realpath, Context->realpath) == 0))
       OpnIndex = EntryCount;
 
     EntryCount++;
   }

Attachment: signature.asc
Description: PGP signature

Reply via email to