Fix search wrap-around offsets.

This commit is contained in:
Aldo Cortesi 2015-03-29 14:39:47 +13:00
parent 8a0404ddf8
commit e4738bdd39

View File

@ -19,7 +19,6 @@ class Searchable(urwid.ListBox):
self, self,
urwid.SimpleFocusListWalker(contents) urwid.SimpleFocusListWalker(contents)
) )
self.search_offset = 0 self.search_offset = 0
self.current_highlight = None self.current_highlight = None
self.search_term = None self.search_term = None
@ -68,7 +67,7 @@ class Searchable(urwid.ListBox):
if backwards: if backwards:
rng = xrange(len(self.body)-1, -1, -1) rng = xrange(len(self.body)-1, -1, -1)
else: else:
rng = xrange(1, len(self.body)) rng = xrange(1, len(self.body) + 1)
for i in rng: for i in rng:
off = (self.focus_position + i)%len(self.body) off = (self.focus_position + i)%len(self.body)
w = self.body[off] w = self.body[off]