summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/container/history.py22
-rw-r--r--ranger/core/environment.py4
-rw-r--r--ranger/fsobject/directory.py4
-rw-r--r--ranger/gui/widgets/console.py1
4 files changed, 22 insertions, 9 deletions
diff --git a/ranger/container/history.py b/ranger/container/history.py
index 9a3d6c4a..d7a45500 100644
--- a/ranger/container/history.py
+++ b/ranger/container/history.py
@@ -17,17 +17,25 @@ class HistoryEmptyException(Exception):
 	pass
 
 class History(object):
-	def __init__(self, maxlen=None):
+	def __init__(self, maxlen=None, unique=True):
 		self._history = []
 		self._index = 0
 		self.maxlen = maxlen
+		self.unique = unique
 
 	def add(self, item):
+		# Remove everything after index
+		if self._index < len(self._history) - 2:
+			del self._history[:self._index+1]
 		# Remove Duplicates
-		try:
-			self._history.remove(item)
-		except:
-			pass
+		if self.unique:
+			try:
+				self._history.remove(item)
+			except:
+				pass
+		else:
+			if self._history and self._history[-1] == item:
+				del self._history[-1]
 		# Remove first if list is too long
 		if len(self._history) > self.maxlen - 1:
 			del self._history[0]
@@ -72,6 +80,7 @@ class History(object):
 		self._index -= 1
 		if self._index < 0:
 			self._index = 0
+		return self.current()
 
 	def move(self, n):
 		self._index += n
@@ -79,6 +88,7 @@ class History(object):
 			self._index = len(self._history) - 1
 		if self._index < 0:
 			self._index = 0
+		return self.current()
 
 	def search(self, string, n):
 		if n != 0 and string:
@@ -93,6 +103,7 @@ class History(object):
 					steps_left -= 1
 			if steps_left != steps_left_at_start:
 				self._index = i
+		return self.current()
 
 	def __iter__(self):
 		return self._history.__iter__()
@@ -107,6 +118,7 @@ class History(object):
 				self._index = len(self._history) - 1
 		else:
 			self._index = 0
+		return self.current()
 
 	def fast_forward(self):
 		if self._history:
diff --git a/ranger/core/environment.py b/ranger/core/environment.py
index fca2168b..61db8694 100644
--- a/ranger/core/environment.py
+++ b/ranger/core/environment.py
@@ -54,7 +54,7 @@ class Environment(SettingsAware, SignalDispatcher):
 		self.keybuffer = KeyBuffer(None, None)
 		self.keymanager = KeyManager(self.keybuffer, ALLOWED_CONTEXTS)
 		self.copy = set()
-		self.history = History(self.settings.max_history_size)
+		self.history = History(self.settings.max_history_size, unique=False)
 
 		try:
 			self.username = pwd.getpwuid(os.geteuid()).pw_name
@@ -166,7 +166,7 @@ class Environment(SettingsAware, SignalDispatcher):
 	def history_go(self, relative):
 		"""Move relative in history"""
 		if self.history:
-			self.history.move(relative).go()
+			self.history.move(relative).go(history=False)
 
 	def enter_dir(self, path, history = True):
 		"""Enter given path"""
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index f1bcd9a3..05c07009 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -420,10 +420,10 @@ class Directory(FileSystemObject, Accumulator, SettingsAware):
 			return True
 		return self.last_used + seconds < time()
 
-	def go(self):
+	def go(self, history=True):
 		"""enter the directory if the filemanager is running"""
 		if self.fm:
-			return self.fm.enter_dir(self.path)
+			return self.fm.enter_dir(self.path, history=history)
 		return False
 
 	def empty(self):
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index 89bd4a3a..57264292 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -112,6 +112,7 @@ class Console(Widget):
 		self.pos = len(string)
 		if position is not None:
 			self.pos = min(self.pos, position)
+		self.history.fast_forward()
 		self.history.add('')
 		return True
 
lass='oid'>2c477cf ^
8012fcf ^



2c477cf ^

8012fcf ^

89b7f15 ^
2c477cf ^


8012fcf ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154