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:
Grant Murphy 2018-05-25 11:38:08 +10:00
parent f910f361a0
commit bd7069a9e0
2 changed files with 3 additions and 0 deletions

View File

@ -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):

View File

@ -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)