about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2021-07-15 23:37:58 +0200
committertoonn <toonn@toonn.io>2021-07-20 23:17:45 +0200
commitf22d23acb2c151a68ca5ba41a7de6cc6ed3261a0 (patch)
tree37209f0b169c4c59aa73605ac005aa2068128d02
parent71b398c95289c730a5df0ccd50eec8266926da42 (diff)
downloadranger-f22d23acb2c151a68ca5ba41a7de6cc6ed3261a0.tar.gz
history: Replace branching with min/max builtins
-rw-r--r--ranger/container/history.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/ranger/container/history.py b/ranger/container/history.py
index 9361e373..d271176d 100644
--- a/ranger/container/history.py
+++ b/ranger/container/history.py
@@ -108,17 +108,11 @@ class History(object):
             raise HistoryEmptyException
 
     def back(self):
-        self.index -= 1
-        if self.index < 0:
-            self.index = 0
+        self.index = max(0, self.index - 1)
         return self.current()
 
     def move(self, n):
-        self.index += n
-        if self.index > len(self.history) - 1:
-            self.index = len(self.history) - 1
-        if self.index < 0:
-            self.index = 0
+        self.index = max(0, min(self.history - 1, self.index + n))
         return self.current()
 
     def search(self, string, n):