From f3243faa22ffd78ef654cd7ae4357a908408ac19 Mon Sep 17 00:00:00 2001 From: hut Date: Sun, 16 Jul 2017 06:12:32 +0200 Subject: container.directory: no need to Ctrl+R on ":set vcs_aware!" this is done through setting the "vcs" attribute to a lazy_property and binding its __reset() function to the signal 'setopt.vcs_aware'. --- ranger/container/directory.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ranger/container/directory.py b/ranger/container/directory.py index fbbf4d22..c73e2408 100644 --- a/ranger/container/directory.py +++ b/ranger/container/directory.py @@ -129,8 +129,8 @@ class Directory( # pylint: disable=too-many-instance-attributes,too-many-public content_outdated = False content_loaded = False - vcs = None has_vcschild = False + _vcs_signal_handler_installed = False cumulative_size_calculated = False @@ -167,11 +167,18 @@ class Directory( # pylint: disable=too-many-instance-attributes,too-many-public self.settings = LocalSettings(path, self.settings) - if self.settings.vcs_aware: - self.vcs = Vcs(self) - self.use() + @lazy_property + def vcs(self): + if not self._vcs_signal_handler_installed: + self.settings.signal_bind('setopt.vcs_aware', + self.vcs__reset, # pylint: disable=no-member + weak=True, autosort=False) + self._vcs_signal_handler_installed = True + if self.settings.vcs_aware: + return Vcs(self) + def signal_function_factory(self, function): def signal_function(): self.load_if_outdated() -- cgit 1.4.1-2-gfad0