I've written a test case in Python to reproduce this bug. It could easily be
turned into a DEP 8 automatic package test.

The output looks like this:

q:Exit  -:PrevPg  <Space>:NextPg v:View Attachm.  d:Del  r:Reply  j:Next ?:Help 
 m0     0|   1 N   Oct 10 test@test       (  24) test                           
 m1     0|-*-Mutt: =tmppaeZ8M [Msgs:1 2.3K]---(threads/date)------------(all)---
 m2     0|wwwwwwww ggggg lllllll u aaaaaaaaa llllllll aaaaa                     
 m3     0|ffffffffff x aaaaaa yyyy fffff aaa lllll ggg fffff h vvvvvv qq        
 m4     0|+zzzzzzzzz dddd ssssssss yyyyy                                        
 m5     0|rrrr ppppppppp wwwwww p gggggggg kk oooooooo rrrr llllll uuuuuu kkkkk 
 m6     0|+a ssssssssss pppp eeeeee zzzzzzzz ooooooooo gggggg                   
 m7     0|ppppp hhhhhh y uuuuuuuuu xxxxxxxx vvvvvv ooooo bbbbbbbbb oo nnnnn jjjj
          +ooooooo ppppp aaa eeeeee wwwwwwww uuuuuuuuu ggggggggg r a            
          gg qqqq bb nn hhhhhhhh llll m kkkkk ee xxxxxx fffffff v aa ss sssssss 
          +ooo zzzzzzzz                                                         
          fffffff kkkkkk iiiiiii bbb zzzzzzzzz hhhhhhhhh iiiiiiiiii ttttt g w   
 m12    0|+vvvvvvvvvv oo wwwwwwwwww                                             
 m13    0|nnnn jjj rrrrr ff rrr mmmm wwwwwwwww aaa iiiiiiiiii uuuu fffffff      
 m14    0|+vvvvvvvvvv iiiiiiiii rrrrr zzz s                                     
 m15    0|xxx ttttttt vvvv iii wwwwwww yyyyyyyyy dddddd                         
 m16    0|b wwwwwwww vvvv pppppppp jjjjjj f                                     
 m17    0|xxxxxx yyyyy hhhhhhhh v r ccccccccc bbb zzzzz dd                      
 m18    0|tt xxxx zzzzzzzzzz hhh mm q aaaaaaaaaa hhhhhh                         
 m19    0|i xxxxxxxxxx zz fffffff zzzzzz rrrrrrr gggggg hhh ccc zzzzz qqqqqqq   
 m20    0|+yyyy                                                                 
 m21    0|-N  - 1/1: test@test              test                        -- (41%)

You can see a gap in the list of mailboxes in the sidebar.

Here is the code. The python-pyte and python-pexpect packages need to be
installed.

import pyte
import pexpect
from random import seed, randint
from tempfile import NamedTemporaryFile
import os

def write_muttrc(f):
    f.write('''
set folder=/tmp
set sidebar_visible
set sidebar_width=10
set pager_index_lines=4

mailboxes ''')

    for i in range(30):
        f.write(' =m{}'.format(i))

def write_mbox(f):
    for line in ('From test@test Sat Oct 10 10:00:00 2015',
                 'Subject: test', 'To: test@test', 'From: test@test', ''):
        print >> f, line
    seed(1)
    for i in range(25):
        print >> f, ' '.join(chr(ord('a') + randint(0, 25)) * randint(1, 10)
                             for i in range(randint(5, 20)))

def run_mutt(muttrc, mbox):
    stream = pyte.ByteStream()
    screen = pyte.Screen(80, 24)
    stream.attach(screen)
    mutt = pexpect.spawn('/usr/bin/mutt-patched', ['-F', muttrc, '-f', mbox])
    mutt.send('\n' * 5)
    while True:
        try:
            buf = mutt.read_nonblocking(mutt.maxread, timeout=1)
        except pexpect.TIMEOUT:
            break
        stream.feed(buf)
    mutt.send('q')
    return screen

def main():
    f = NamedTemporaryFile(delete=False)
    muttrc = f.name
    write_muttrc(f)
    f.close()

    f = NamedTemporaryFile(delete=False)
    mbox = f.name
    write_mbox(f)
    f.close()

    for line in run_mutt(muttrc, mbox).display:
        print line

    os.remove(muttrc)
    os.remove(mbox)

if __name__ == '__main__':
    main()

Reply via email to