mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
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
This commit is contained in:
parent
f910f361a0
commit
bd7069a9e0
@ -107,6 +107,7 @@ class OptManager:
|
|||||||
choices: typing.Optional[typing.Sequence[str]] = None
|
choices: typing.Optional[typing.Sequence[str]] = None
|
||||||
) -> None:
|
) -> None:
|
||||||
self._options[name] = _Option(name, typespec, default, help, choices)
|
self._options[name] = _Option(name, typespec, default, help, choices)
|
||||||
|
self.changed.send(self, updated={name})
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def rollback(self, updated, reraise=False):
|
def rollback(self, updated, reraise=False):
|
||||||
|
@ -106,6 +106,8 @@ class OptionListWalker(urwid.ListWalker):
|
|||||||
self.master.options.changed.connect(self.sig_mod)
|
self.master.options.changed.connect(self.sig_mod)
|
||||||
|
|
||||||
def sig_mod(self, *args, **kwargs):
|
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._modified()
|
||||||
self.set_focus(self.index)
|
self.set_focus(self.index)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user