Fix #4614 Options and Keybinding screen: home and end crash mitmproxy (#4693)

* Fix #4614 Options and Keybinding screen: home and end crash mitmproxy

* fix flake8

* Add integration test for fix to #4614

* fix the flake8, again.
This commit is contained in:
Brad Dixon 2021-08-02 13:18:22 -04:00 committed by GitHub
parent 3b87d3f66e
commit 68cc3e721f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -66,6 +66,7 @@ class KeyListWalker(urwid.ListWalker):
self.index = index
self.focus_obj = self._get(self.index)
keybinding_focus_change.send(binding.help or "")
self._modified()
def get_next(self, pos):
if pos >= len(self.bindings) - 1:
@ -79,6 +80,12 @@ class KeyListWalker(urwid.ListWalker):
return None, None
return self._get(pos), pos
def positions(self, reverse=False):
if reverse:
return reversed(range(len(self.bindings)))
else:
return range(len(self.bindings))
class KeyList(urwid.ListBox):
def __init__(self, master):

View File

@ -142,6 +142,7 @@ class OptionListWalker(urwid.ListWalker):
self.index = index
self.focus_obj = self._get(self.index, self.editing)
option_focus_change.send(opt.help)
self._modified()
def get_next(self, pos):
if pos >= len(self.opts) - 1:
@ -155,6 +156,12 @@ class OptionListWalker(urwid.ListWalker):
return None, None
return self._get(pos, False), pos
def positions(self, reverse=False):
if reverse:
return reversed(range(len(self.opts)))
else:
return range(len(self.opts))
class OptionsList(urwid.ListBox):
def __init__(self, master):

View File

@ -43,3 +43,11 @@ def test_integration(tdata, console):
console.type(f":view.flows.load {tdata.path('mitmproxy/data/dumpfile-7.mitm')}<enter>")
console.type("<enter><tab><tab>")
console.type("<space><tab><tab>") # view second flow
def test_options_home_end(console):
console.type("O<home><end>")
def test_keybindings_home_end(console):
console.type("K<home><end>")