Projects STRLCPY neomutt Commits 78a1eb16
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■
    email/email.c
    skipped 76 lines
    77 77   */
    78 78  struct Email *email_new(void)
    79 79  {
    80  - static size_t sequence = 0;
     80 + static size_t sequence = 1;
    81 81   
    82 82   struct Email *e = mutt_mem_calloc(1, sizeof(struct Email));
    83 83  #ifdef MIXMASTER
    skipped 168 lines
  • ■ ■ ■ ■ ■ ■
    mview.c
    skipped 33 lines
    34 34  #include "core/lib.h"
    35 35  #include "mview.h"
    36 36  #include "imap/lib.h"
     37 +#include "menu/lib.h"
    37 38  #include "ncrypt/lib.h"
    38 39  #include "pattern/lib.h"
    39 40  #include "mutt_header.h"
    40 41  #include "mutt_thread.h"
     42 +#include "mview.h"
    41 43  #include "mx.h"
    42 44  #include "score.h"
    43 45  #include "sort.h"
    skipped 264 lines
    308 310  }
    309 311   
    310 312  /**
     313 + * find_email_index_by_seq - Find an Email's virtual position from its sequence number
     314 + * @param m Mailbox
     315 + * @param seq Sequence number
     316 + * @retval num Virtual position (row in Menu)
     317 + * @retval -1 Sequence number not found
     318 + */
     319 +int find_email_index_by_seq(struct Mailbox *m, size_t seq)
     320 +{
     321 + if (!m || (seq == 0))
     322 + return -1;
     323 + 
     324 + struct Email *e = NULL;
     325 + for (int vnum = 0; vnum < m->vcount; vnum++)
     326 + {
     327 + e = mutt_get_virt_email(m, vnum);
     328 + if (e->sequence == seq)
     329 + return vnum;
     330 + }
     331 + 
     332 + return -1;
     333 +}
     334 + 
     335 +/**
    311 336   * mview_mailbox_observer - Notification that a Mailbox has changed - Implements ::observer_t - @ingroup observer_api
    312 337   */
    313 338  int mview_mailbox_observer(struct NotifyCallback *nc)
    skipped 4 lines
    318 343   return -1;
    319 344   
    320 345   struct MailboxView *mv = nc->global_data;
     346 + struct Mailbox *m = mv->mailbox;
     347 + 
     348 + size_t seq = 0;
     349 + int idx = menu_get_index(mv->menu);
     350 + struct Email *e = mutt_get_virt_email(m, idx);
     351 + if (e)
     352 + {
     353 + seq = e->sequence;
     354 + }
    321 355   
    322 356   switch (nc->event_subtype)
    323 357   {
    skipped 13 lines
    337 371   default:
    338 372   return 0;
    339 373   }
     374 + 
     375 + idx = find_email_index_by_seq(m, seq);
     376 + if (idx != -1)
     377 + menu_set_index(mv->menu, idx);
    340 378   
    341 379   mutt_debug(LL_DEBUG5, "mailbox done\n");
    342 380   return 0;
    skipped 108 lines
Please wait...
Page is in error, reload to recover