aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy
diff options
context:
space:
mode:
authorHenrique <typoon@gmail.com>2019-11-25 18:55:12 -0500
committerHenrique <typoon@gmail.com>2019-11-25 18:55:12 -0500
commit8449db103ea8a8514d9c1b94ddb197efee689240 (patch)
treedb5c65b7b11b01e3db8b60039e5d743559ee2949 /mitmproxy
parent046779615f0a492d567300f08de79eaf5f780d84 (diff)
downloadmitmproxy-8449db103ea8a8514d9c1b94ddb197efee689240.tar.gz
mitmproxy-8449db103ea8a8514d9c1b94ddb197efee689240.tar.bz2
mitmproxy-8449db103ea8a8514d9c1b94ddb197efee689240.zip
Fixed `ctrl w`
Diffstat (limited to 'mitmproxy')
-rw-r--r--mitmproxy/tools/console/commander/commander.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/mitmproxy/tools/console/commander/commander.py b/mitmproxy/tools/console/commander/commander.py
index feaa4e36..46c1cb96 100644
--- a/mitmproxy/tools/console/commander/commander.py
+++ b/mitmproxy/tools/console/commander/commander.py
@@ -222,13 +222,19 @@ class CommandEdit(urwid.WidgetWrap):
pos = len(self.cbuf.text)
self.cbuf.cursor = pos
elif key == "ctrl w":
- txt = self.cbuf.text.strip()
- if(txt != ''):
- chunks = txt.split(' ')[0:-1]
- if len(chunks) == 0:
- self.cbuf.set_text(' '.join(chunks))
- else:
- self.cbuf.set_text(' '.join(chunks) + ' ')
+ prev_cursor = self.cbuf.cursor
+ pos = self.cbuf.text.rfind(' ', 0, self.cbuf.cursor - 1)
+ if pos == -1:
+ new_text = self.cbuf.text[self.cbuf.cursor:]
+ cursor_pos = 0
+ else:
+ txt_after = self.cbuf.text[self.cbuf.cursor:]
+ txt_before = self.cbuf.text[0:pos]
+ new_text = f"{txt_before} {txt_after}"
+ cursor_pos = prev_cursor - (prev_cursor - pos) + 1
+
+ self.cbuf.set_text(new_text)
+ self.cbuf.cursor = cursor_pos
elif key == "backspace":
self.cbuf.backspace()
elif key == "left" or key == "ctrl b":