aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhut <hut@hut.pm>2017-07-16 06:12:32 +0200
committerhut <hut@hut.pm>2017-07-16 06:13:05 +0200
commitf3243faa22ffd78ef654cd7ae4357a908408ac19 (patch)
treed5c5c3f505ef2f9336101babf8d84cba155dc7a4
parent064ac63da1acebd56e5bbf5ae7fe57fda8eb7bbc (diff)
downloadranger-f3243faa22ffd78ef654cd7ae4357a908408ac19.tar.gz
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'.
-rw-r--r--ranger/container/directory.py15
1 files 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()