diff options
author | nfnty <git@nfnty.se> | 2017-07-30 15:58:59 +0200 |
---|---|---|
committer | nfnty <git@nfnty.se> | 2017-07-30 15:58:59 +0200 |
commit | a81b6ecf750aba0eb9efceea88f43ffbf3729700 (patch) | |
tree | ae71220bf20a582ba57e26e971cadc56665492b9 | |
parent | 1bbee381f5c25f903cd70d2d56d6204cadf373dd (diff) | |
parent | bd1cd0d67060f8305655e2edb1ba095c7e1445ac (diff) | |
download | ranger-a81b6ecf750aba0eb9efceea88f43ffbf3729700.tar.gz |
Merge remote-tracking branch 'Vifon/vifon/pagewise-movement-symmetry'
-rw-r--r-- | ranger/ext/direction.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/ranger/ext/direction.py b/ranger/ext/direction.py index bbb69c9b..e337c26e 100644 --- a/ranger/ext/direction.py +++ b/ranger/ext/direction.py @@ -20,6 +20,8 @@ False from __future__ import (absolute_import, division, print_function) +import math + class Direction(dict): @@ -142,8 +144,16 @@ class Direction(dict): if self.cycle(): cycles, pos = divmod(pos, (maximum + offset - minimum)) self['_move_cycles'] = int(cycles) - return int(minimum + pos) - return int(max(min(pos, maximum + offset - 1), minimum)) + ret = minimum + pos + else: + ret = max(min(pos, maximum + offset - 1), minimum) + # Round towards the direction we're moving from. + # From the UI point of view, round down. See: #912. + if direction < 0: + ret = int(math.ceil(ret)) + else: + ret = int(ret) + return ret def move_cycles(self): return self.get('_move_cycles', 0) |