about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorMyk <politas@gmail.com>2020-08-02 00:16:35 +1000
committerGitHub <noreply@github.com>2020-08-02 00:16:35 +1000
commit9ddccb282b7fd10bbeb63c5a9df625d95160bcff (patch)
tree3989af89791e462e1db95561204afd2a1e182d85 /ranger
parentc5229b4f56c1c6fb6ec3bc5c6e7c621fa53cfe05 (diff)
parent240d8a0ea1b82690372ba067c24a3f581a29c782 (diff)
downloadranger-9ddccb282b7fd10bbeb63c5a9df625d95160bcff.tar.gz
Merge branch 'master' into fix/1880-multipane-status
Diffstat (limited to 'ranger')
-rw-r--r--ranger/core/tab.py22
-rw-r--r--ranger/gui/widgets/browsercolumn.py2
2 files changed, 22 insertions, 2 deletions
diff --git a/ranger/core/tab.py b/ranger/core/tab.py
index cd30d329..64edf120 100644
--- a/ranger/core/tab.py
+++ b/ranger/core/tab.py
@@ -19,7 +19,9 @@ class Tab(FileManagerAware, SettingsAware):  # pylint: disable=too-many-instance
         self._thisfile = None  # Current File
         self.history = History(self.settings.max_history_size, unique=False)
         self.last_search = None
-        self.pointer = 0
+        self._pointer = 0
+        self._pointed_obj = None
+        self.pointed_obj = None
         self.path = abspath(expanduser(path))
         self.pathway = ()
         # NOTE: in the line below, weak=True works only in python3.  In python2,
@@ -36,6 +38,7 @@ class Tab(FileManagerAware, SettingsAware):  # pylint: disable=too-many-instance
             self._thisfile = signal.new
             if self == self.fm.thistab:
                 self.pointer = self.thisdir.pointer
+                self.pointed_obj = self.thisdir.pointed_obj
 
     def _on_tab_change(self, signal):
         if self == signal.new and self.thisdir:
@@ -53,6 +56,23 @@ 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]
+        return self._pointer
+
+    def _set_pointer(self, value):
+        self._pointer = value
+        self._pointed_obj = self.thisdir.files[self._pointer]
+
+    pointer = property(_get_pointer, _set_pointer)
+
     def at_level(self, level):
         """Returns the FileSystemObject at the given level.
 
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 330823b3..e6f5180f 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -413,7 +413,7 @@ class BrowserColumn(Pager):  # pylint: disable=too-many-instance-attributes
             self.color_reset()
 
     def _get_index_of_selected_file(self):
-        if self.fm.ui.viewmode == 'multipane' and self.tab:
+        if self.fm.ui.viewmode == 'multipane' and self.tab != self.fm.thistab:
             return self.tab.pointer
         return self.target.pointer