pazz / alot

Terminal-based Mail User Agent
GNU General Public License v3.0
699 stars 164 forks source link

list index out of range in completion #535

Open 6E006B opened 11 years ago

6E006B commented 11 years ago

I'll just leave this here quickly, since I have to get up early tomorrow ;)

Traceback (most recent call last):
  File "/home/chriz/.local/bin/alot", line 20, in <module>
    main()
  File "/home/chriz/.local/lib/python2.7/site-packages/alot/init.py", line 185, in main
    UI(dbman, cmd)
  File "/home/chriz/.local/lib/python2.7/site-packages/alot/ui.py", line 89, in __init__
    self.mainloop.run()
  File "/usr/lib/pymodules/python2.7/urwid/main_loop.py", line 170, in run
    self.screen.run_wrapper(self._run)
  File "/usr/lib/pymodules/python2.7/urwid/raw_display.py", line 234, in run_wrapper
    return fn()
  File "/usr/lib/pymodules/python2.7/urwid/main_loop.py", line 188, in _run
    self.event_loop.run()
  File "/usr/lib/pymodules/python2.7/urwid/main_loop.py", line 872, in wrapper
    return f(*args,**kargs)
  File "/usr/lib/pymodules/python2.7/urwid/main_loop.py", line 234, in _update
    self.process_input(keys)
  File "/usr/lib/pymodules/python2.7/urwid/main_loop.py", line 319, in process_input
    k = self.widget.keypress(self.screen_size, k)
  File "/usr/lib/pymodules/python2.7/urwid/container.py", line 355, in keypress
    *self.calculate_padding_filler(size, True)), key)
  File "/usr/lib/pymodules/python2.7/urwid/container.py", line 1333, in keypress
    key = w.keypress( (mc,)+size[1:], key )
  File "/home/chriz/.local/lib/python2.7/site-packages/alot/widgets/globals.py", line 93, in keypress
    self.completer.complete(self.edit_text, self.edit_pos)
  File "/home/chriz/.local/lib/python2.7/site-packages/alot/completion.py", line 470, in complete
    cstart, cend = self.get_context(line, pos)
  File "/home/chriz/.local/lib/python2.7/site-packages/alot/completion.py", line 466, in get_context
    end += 1 + len(commands[i])
IndexError: list index out of range

It happened as I was refining my search. Last entries of the debug log:

DEBUG:ui:Got key (['|'], [124])
DEBUG:ui:cmdline: 'refineprompt'
DEBUG:__init__:mode:search got commandline "refineprompt"
DEBUG:__init__:ARGS: [u'refineprompt']
DEBUG:__init__:cmd parms {}
INFO:ui:apply command: <alot.commands.search.RefinePromptCommand object at 0x1ef3c50>
INFO:ui:apply command: <alot.commands.globals.PromptCommand object at 0x1ef3ed0>
INFO:globals:open command shell
DEBUG:ui:Got key ([' '], [32])
DEBUG:ui:Got key (['a'], [97])
DEBUG:ui:Got key (['n'], [110])
DEBUG:ui:Got key (['d'], [100])
DEBUG:ui:Got key ([' '], [32])
DEBUG:ui:Got key (['t'], [116])
DEBUG:ui:Got key (['a'], [97])
DEBUG:ui:Got key (['g'], [103])
DEBUG:ui:Got key (['tab'], [9])
pazz commented 11 years ago

hmm.. cannot reproduce on master/testing. what was your search query?

6E006B commented 11 years ago

I can reproduce this as following:

'L' for tag list. Select the 'twitter' tag. '|' for refineprompt. Typing ' and tag'. Then hitting '[tab]' causes this exception.

pazz commented 11 years ago

Quoting Christopher Schwardt (2012-11-08 12:37:25)

I can reproduce this as following:

'L' for tag list. Select the 'twitter' tag. '|' for refineprompt. Typing ' and tag'. Then hitting '[tab]' causes this exception.

yep, can reproduce this now. thx

pazz commented 11 years ago

you hit sth deeper here unfortunately. the problem is that the first tagstring is quoted. I split ";" separated commands and later on parameter arguments using shlex, which sucks big time. need to look deeper into how to properly fix alot.helper.split_commandline.. a quick fix would be to simple escape " chars there before handing the string to shlex. this unfortunately makes alots shellescape cmd behave strangely..

6E006B commented 11 years ago

You're welcome ;)