about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2012-08-05 15:52:53 +0200
committerhut <hut@lavabit.com>2012-08-05 15:52:53 +0200
commit90ce9ed7545b733fb1ec9e769c10bba6e3fd4ab2 (patch)
treea2de6f9a9cc832ffa41055f259a4b23284c84133
parenta8c5614b8e3092d307b917654eb085f4b8aa87cf (diff)
downloadranger-90ce9ed7545b733fb1ec9e769c10bba6e3fd4ab2.tar.gz
core.tab: save and restore pointer when changing tab
-rw-r--r--ranger/core/tab.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/ranger/core/tab.py b/ranger/core/tab.py
index bf837df3..0244adec 100644
--- a/ranger/core/tab.py
+++ b/ranger/core/tab.py
@@ -14,14 +14,24 @@ class Tab(FileManagerAware, SettingsAware):
 		self._thisfile = None  # Current File
 		self.history = History(self.settings.max_history_size, unique=False)
 		self.last_search = None
+		self.pointer = 0
 		self.path = abspath(expanduser(path))
 		self.pathway = ()
 		self.fm.signal_bind('move', self._set_thisfile_from_signal, priority=0.1,
 				weak=True)
+		self.fm.signal_bind('tab.change', self._on_tab_change, weak=True)
 
 	def _set_thisfile_from_signal(self, signal):
 		if self == signal.tab:
 			self._thisfile = signal.new
+			if self == self.fm.thistab:
+				self.pointer = self.thisdir.pointer
+
+	def _on_tab_change(self, signal):
+		if self == self.fm.thistab and self.thisdir:
+			# restore the pointer whenever this tab is reopened
+			self.thisdir.pointer = self.pointer
+			self.thisdir.correct_pointer()
 
 	def _set_thisfile(self, value):
 		if value is not self._thisfile: