diff options
author | toonn <toonn@toonn.io> | 2020-08-01 12:19:50 +0200 |
---|---|---|
committer | toonn <toonn@toonn.io> | 2020-08-01 12:19:50 +0200 |
commit | 240d8a0ea1b82690372ba067c24a3f581a29c782 (patch) | |
tree | c4cd5302365dfa016692c9eb4568d0ffe2d71303 /ranger | |
parent | b92366f5308666f03a3418519c1b1700ed7e86fe (diff) | |
parent | 53c1eaab8c04971962ae2f131106eccc9454aa7b (diff) | |
download | ranger-240d8a0ea1b82690372ba067c24a3f581a29c782.tar.gz |
Merge branch 'multipane-selection'
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/core/tab.py | 22 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 2 |
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 |