diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-12-11 14:50:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-11 14:50:13 +0100 |
commit | 610433f204d6a8774ec0b16c5b08c40c33aeccfe (patch) | |
tree | 5756e0c3c32f5883cb1ae4c095db60d7b22831f7 | |
parent | 402332708724797713630af7f41cc2cabd79898e (diff) | |
parent | 265ab7bf26840c06046d8eb30428575248f69488 (diff) | |
download | mitmproxy-610433f204d6a8774ec0b16c5b08c40c33aeccfe.tar.gz mitmproxy-610433f204d6a8774ec0b16c5b08c40c33aeccfe.tar.bz2 mitmproxy-610433f204d6a8774ec0b16c5b08c40c33aeccfe.zip |
Merge pull request #1839 from mhils/1830
fix #1830
-rw-r--r-- | mitmproxy/addons/view.py | 6 | ||||
-rw-r--r-- | mitmproxy/tools/console/flowlist.py | 6 |
2 files changed, 7 insertions, 5 deletions
diff --git a/mitmproxy/addons/view.py b/mitmproxy/addons/view.py index b8b6093f..dd5b745d 100644 --- a/mitmproxy/addons/view.py +++ b/mitmproxy/addons/view.py @@ -145,9 +145,9 @@ class View(collections.Sequence): def inbounds(self, index: int) -> bool: """ - Is this index >= 0 and < len(self) + Is this 0 <= index < len(self) """ - return index >= 0 and index < len(self) + return 0 <= index < len(self) def _rev(self, idx: int) -> int: """ @@ -359,7 +359,7 @@ class Focus: return self.view.index(self.flow) @index.setter - def index(self, idx) -> typing.Optional[int]: + def index(self, idx): if idx < 0 or idx > len(self.view) - 1: raise ValueError("Index out of view bounds") self.flow = self.view[idx] diff --git a/mitmproxy/tools/console/flowlist.py b/mitmproxy/tools/console/flowlist.py index d7c312e5..fee215c6 100644 --- a/mitmproxy/tools/console/flowlist.py +++ b/mitmproxy/tools/console/flowlist.py @@ -355,9 +355,11 @@ class FlowListBox(urwid.ListBox): elif key == "e": self.master.toggle_eventlog() elif key == "g": - self.master.view.focus.index = 0 + if len(self.master.view): + self.master.view.focus.index = 0 elif key == "G": - self.master.view.focus.index = len(self.master.view) - 1 + if len(self.master.view): + self.master.view.focus.index = len(self.master.view) - 1 elif key == "f": signals.status_prompt.send( prompt = "Filter View", |