aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/tools
diff options
context:
space:
mode:
authorHenrique <typoon@gmail.com>2019-11-24 20:13:25 -0500
committerHenrique <typoon@gmail.com>2019-11-24 20:13:25 -0500
commit7b386d5393a68715e70a9ea6d2936c8b09104f86 (patch)
tree125e23d4136921ea7dc9f2508a482dd021e2ff1f /mitmproxy/tools
parent1d43abcb289823107bd305ed2485af0c3986a270 (diff)
downloadmitmproxy-7b386d5393a68715e70a9ea6d2936c8b09104f86.tar.gz
mitmproxy-7b386d5393a68715e70a9ea6d2936c8b09104f86.tar.bz2
mitmproxy-7b386d5393a68715e70a9ea6d2936c8b09104f86.zip
Fixed the logic according to some tests, added new tests
Diffstat (limited to 'mitmproxy/tools')
-rw-r--r--mitmproxy/tools/console/commander/commander.py30
-rw-r--r--mitmproxy/tools/console/statusbar.py2
2 files changed, 26 insertions, 6 deletions
diff --git a/mitmproxy/tools/console/commander/commander.py b/mitmproxy/tools/console/commander/commander.py
index 99533cfa..ac313290 100644
--- a/mitmproxy/tools/console/commander/commander.py
+++ b/mitmproxy/tools/console/commander/commander.py
@@ -153,26 +153,46 @@ class CommandEdit(urwid.WidgetWrap):
def __init__(self, master: mitmproxy.master.Master, text: str) -> None:
super().__init__(urwid.Text(self.leader))
self.master = master
+ self.active_filter = False
+ self.filter_str = ''
self.cbuf = CommandBuffer(master, text)
self.update()
def keypress(self, size, key) -> None:
if key == "backspace":
self.cbuf.backspace()
+ if self.cbuf.text == '':
+ self.active_filter = False
+ self.master.commands.execute("command_history.filter ''")
+ self.filter_str = ''
elif key == "left":
self.cbuf.left()
elif key == "right":
self.cbuf.right()
elif key == "up":
- _cmd = command_lexer.quote(self.cbuf.text)
- self.master.commands.execute("command_history.filter %s" % _cmd)
+ if self.active_filter is False:
+ self.active_filter = True
+ self.filter_str = self.cbuf.text
+ _cmd = command_lexer.quote(self.cbuf.text)
+ self.master.commands.execute("command_history.filter %s" % _cmd)
+
cmd = self.master.commands.execute("command_history.prev")
self.cbuf = CommandBuffer(self.master, cmd)
elif key == "down":
- _cmd = command_lexer.quote(self.cbuf.text)
- self.master.commands.execute("command_history.filter %s" % _cmd)
+ prev_cmd = self.cbuf.text
cmd = self.master.commands.execute("command_history.next")
- self.cbuf = CommandBuffer(self.master, cmd)
+
+ if cmd == '':
+ if prev_cmd == self.filter_str:
+ self.cbuf = CommandBuffer(self.master, prev_cmd)
+ else:
+ self.active_filter = False
+ self.master.commands.execute("command_history.filter ''")
+ self.filter_str = ''
+ self.cbuf = CommandBuffer(self.master, '')
+ else:
+ self.cbuf = CommandBuffer(self.master, cmd)
+
elif key == "shift tab":
self.cbuf.cycle_completion(False)
elif key == "tab":
diff --git a/mitmproxy/tools/console/statusbar.py b/mitmproxy/tools/console/statusbar.py
index 6d040d92..39141b97 100644
--- a/mitmproxy/tools/console/statusbar.py
+++ b/mitmproxy/tools/console/statusbar.py
@@ -141,7 +141,7 @@ class ActionBar(urwid.WidgetWrap):
self.prompt_execute(k)
elif k == "enter":
cmd = command_lexer.quote(self._w.cbuf.text)
- self.master.commands.execute(f"command_history.add {cmd} true")
+ self.master.commands.execute(f"command_history.add {cmd}")
self.prompt_execute(self._w.get_edit_text())
else:
if common.is_keypress(k):