diff options
author | toonn <toonn@toonn.io> | 2021-01-05 18:56:08 +0100 |
---|---|---|
committer | toonn <toonn@toonn.io> | 2021-01-05 19:15:58 +0100 |
commit | f1c5ff1e9086f7fbe6c610c53b15cacddcef036b (patch) | |
tree | 67843270cc0444b325116ae0857939bb10c3af3e /ranger | |
parent | 790d90853504f62e9449844a6481f3955190e35d (diff) | |
download | ranger-f1c5ff1e9086f7fbe6c610c53b15cacddcef036b.tar.gz |
Refactor error checking for _pointed_obj
Fixes #2086 Fixes #2125 Fixes #2136 Fixes #2173 Fixes #2205 Fixes #2209
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/core/tab.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/ranger/core/tab.py b/ranger/core/tab.py index b61a77cc..3a0fb943 100644 --- a/ranger/core/tab.py +++ b/ranger/core/tab.py @@ -57,23 +57,21 @@ class Tab(FileManagerAware, SettingsAware): # pylint: disable=too-many-instance thisfile = property(_get_thisfile, _set_thisfile) def _get_pointer(self): - if ( - self.thisdir is not None - and self.thisdir.files[self._pointer] != self._pointed_obj - ): - try: - self._pointer = self.thisdir.files.index(self._pointed_obj) - except ValueError: - self._pointed_obj = self.thisdir.files[self._pointer] + try: + if self.thisdir.files[self._pointer] != self._pointed_obj: + try: + self._pointer = self.thisdir.files.index(self._pointed_obj) + except ValueError: + self._set_pointer(self._pointer) + except (TypeError, IndexError): + pass return self._pointer def _set_pointer(self, value): self._pointer = value try: self._pointed_obj = self.thisdir.files[self._pointer] - except TypeError: - pass - except IndexError: + except (TypeError, IndexError): pass pointer = property(_get_pointer, _set_pointer) |