summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xranger/config/commands.py4
-rw-r--r--ranger/container/directory.py2
-rw-r--r--ranger/ext/vcs/vcs.py20
-rw-r--r--ranger/gui/ui.py7
4 files changed, 28 insertions, 5 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 3e7af7b5..c41bfcb6 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -1360,7 +1360,7 @@ class stage(Command):
                 self.fm.thisdir.vcs.action_add(filelist)
             except VcsError as error:
                 self.fm.notify('Unable to stage files: {0:s}'.format(str(error)))
-            self.fm.ui.vcsthread.wakeup(self.fm.thisdir)
+            self.fm.ui.vcsthread.process(self.fm.thisdir)
         else:
             self.fm.notify('Unable to stage files: Not in repository')
 
@@ -1379,7 +1379,7 @@ class unstage(Command):
                 self.fm.thisdir.vcs.action_reset(filelist)
             except VcsError as error:
                 self.fm.notify('Unable to unstage files: {0:s}'.format(str(error)))
-            self.fm.ui.vcsthread.wakeup(self.fm.thisdir)
+            self.fm.ui.vcsthread.process(self.fm.thisdir)
         else:
             self.fm.notify('Unable to unstage files: Not in repository')
 
diff --git a/ranger/container/directory.py b/ranger/container/directory.py
index 8ace0d85..e7c2b4b6 100644
--- a/ranger/container/directory.py
+++ b/ranger/container/directory.py
@@ -386,7 +386,7 @@ class Directory(FileSystemObject, Accumulator, Loadable):
             self.loading = False
             self.fm.signal_emit("finished_loading_dir", directory=self)
             if self.vcs:
-                self.fm.ui.vcsthread.wakeup(self)
+                self.fm.ui.vcsthread.process(self)
 
     def unload(self):
         self.loading = False
diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py
index fd34c3fe..487c9405 100644
--- a/ranger/ext/vcs/vcs.py
+++ b/ranger/ext/vcs/vcs.py
@@ -370,6 +370,9 @@ class VcsThread(threading.Thread):  # pylint: disable=too-many-instance-attribut
         self.daemon = True
         self.ui = ui  # pylint: disable=invalid-name
         self.queue = queue.Queue()
+        self.advance = threading.Event()
+        self.advance.set()
+        self.paused = threading.Event()
         self.awoken = threading.Event()
         self.timestamp = time.time()
         self.redraw = False
@@ -442,7 +445,12 @@ class VcsThread(threading.Thread):  # pylint: disable=too-many-instance-attribut
 
     def run(self):
         while True:
+            self.paused.set()
+            self.advance.wait()
             self.awoken.wait()
+            if not self.advance.isSet():
+                continue
+            self.paused.clear()
             self.awoken.clear()
 
             self._queue_process()
@@ -455,8 +463,16 @@ class VcsThread(threading.Thread):  # pylint: disable=too-many-instance-attribut
                 self.ui.status.need_redraw = True
                 self.ui.redraw()
 
-    def wakeup(self, dirobj):
-        """Wakeup thread"""
+    def pause(self):
+        """Pause thread"""
+        self.advance.clear()
+
+    def unpause(self):
+        """Unpause thread"""
+        self.advance.set()
+
+    def process(self, dirobj):
+        """Process dirobj"""
         self.queue.put(dirobj)
         self.awoken.set()
 
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index 41b57c2c..ad95d754 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -94,8 +94,15 @@ class UI(DisplayableContainer):
             sys.stdout.write("\033kranger\033\\")
             sys.stdout.flush()
 
+        if 'vcsthread' in self.__dict__:
+            self.vcsthread.unpause()
+
     def suspend(self):
         """Turn off curses"""
+        if 'vcsthread' in self.__dict__:
+            self.vcsthread.pause()
+            self.vcsthread.paused.wait()
+
         self.win.keypad(0)
         curses.nocbreak()
         curses.echo()