diff options
author | 0xjmz <0xjmz@users.noreply.github.com> | 2017-07-31 16:11:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-31 16:11:36 +0200 |
commit | 79a003cb547dd28b09028553562853a365b83e46 (patch) | |
tree | f744350661144cfd1bfc41f8619160570ba2cba8 /ranger | |
parent | 57df5b72d00b140a5083c0bc1427c5542b44221d (diff) | |
parent | 35f47f53a32b29f746c5ddcd4fb367bf2ad7e640 (diff) | |
download | ranger-79a003cb547dd28b09028553562853a365b83e46.tar.gz |
Merge branch 'master' into fix-cursor-movement
Diffstat (limited to 'ranger')
-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) |