summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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()