From bd7069a9e09f8c07add66576b165095acce4dea5 Mon Sep 17 00:00:00 2001 From: Grant Murphy Date: Fri, 25 May 2018 11:38:08 +1000 Subject: Adjust options when changed The existing options for the console were not being updated when a new addon was added. This triggers the changed blinker signal when an option is added, and also recreates self.opts when this signal is received. Fixes #3147 --- mitmproxy/optmanager.py | 1 + mitmproxy/tools/console/options.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/mitmproxy/optmanager.py b/mitmproxy/optmanager.py index a473e9df..2a4beba9 100644 --- a/mitmproxy/optmanager.py +++ b/mitmproxy/optmanager.py @@ -107,6 +107,7 @@ class OptManager: choices: typing.Optional[typing.Sequence[str]] = None ) -> None: self._options[name] = _Option(name, typespec, default, help, choices) + self.changed.send(self, updated={name}) @contextlib.contextmanager def rollback(self, updated, reraise=False): diff --git a/mitmproxy/tools/console/options.py b/mitmproxy/tools/console/options.py index 54772cf0..6e1399ce 100644 --- a/mitmproxy/tools/console/options.py +++ b/mitmproxy/tools/console/options.py @@ -106,6 +106,8 @@ class OptionListWalker(urwid.ListWalker): self.master.options.changed.connect(self.sig_mod) def sig_mod(self, *args, **kwargs): + self.opts = sorted(self.master.options.keys()) + self.maxlen = max(len(i) for i in self.opts) self._modified() self.set_focus(self.index) -- cgit v1.2.3