summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorSamuel Walladge <samuel@swalladge.id.au>2017-02-08 12:25:23 +1030
committernfnty <git@nfnty.se>2017-02-08 04:37:22 +0100
commit3fa65ae8bb8cca86742a4f4bf2980a9827aac748 (patch)
tree10c84ef76f0bcb0777f66a2b554ae998465e5b43 /ranger
parent9e2e196b1c090dcfe179132693f68f9638bc1c6b (diff)
downloadranger-3fa65ae8bb8cca86742a4f4bf2980a9827aac748.tar.gz
config.commands: quit, quitall: Don't exit if loader has work
Fixes #739
Diffstat (limited to 'ranger')
-rwxr-xr-xranger/config/commands.py24
-rw-r--r--ranger/config/rc.conf2
2 files changed, 18 insertions, 8 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index aa955605..012cbbde 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -477,26 +477,33 @@ class default_linemode(Command):
 class quit(Command):  # pylint: disable=redefined-builtin
     """:quit
 
-    Closes the current tab.  If there is only one tab, quit the program.
+    Closes the current tab. If there is only one tab, quit the program.
     """
 
-    def execute(self):
-        if len(self.fm.tabs) <= 1:
+    def _exit_no_work(self):
+        if self.fm.loader.has_work():
+            self.fm.notify('Not quitting: Tasks in progress: Use `quit!` to force quit')
+        else:
             self.fm.exit()
-        self.fm.tab_close()
+
+    def execute(self):
+        if len(self.fm.tabs) >= 2:
+            self.fm.tab_close()
+        else:
+            self._exit_no_work()
 
 
-class quitall(Command):
+class quitall(quit):
     """:quitall
 
     Quits the program immediately.
     """
 
     def execute(self):
-        self.fm.exit()
+        self._exit_no_work()
 
 
-class quit_bang(quitall):
+class quit_bang(Command):
     """:quit!
 
     Quits the program immediately.
@@ -504,6 +511,9 @@ class quit_bang(quitall):
     name = 'quit!'
     allow_abbrev = False
 
+    def execute(self):
+        self.fm.exit()
+
 
 class terminal(Command):
     """:terminal
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index 991c1d3a..0f60c195 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -233,7 +233,7 @@ set wrap_scroll false
 
 alias e    edit
 alias q    quit
-alias q!   quitall
+alias q!   quit!
 alias qa   quitall
 alias qall quitall
 alias setl setlocal