summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-08-28 08:01:42 +0200
committerhut <hut@lavabit.com>2010-08-28 08:01:42 +0200
commitb80a91f6fc0f8fb7af50fff9956d54da20304c9c (patch)
treeba26d54a0f9616f6b507c15c0b6cd1a5d017120c
parenta02baa3311a469a021ed0f801d3a743ecb1ace41 (diff)
downloadranger-b80a91f6fc0f8fb7af50fff9956d54da20304c9c.tar.gz
Integrated new container.history implementation
-rw-r--r--ranger/defaults/commands.py4
-rw-r--r--ranger/gui/widgets/console.py11
2 files changed, 9 insertions, 6 deletions
diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py
index b6e77697..adc166df 100644
--- a/ranger/defaults/commands.py
+++ b/ranger/defaults/commands.py
@@ -107,7 +107,7 @@ class search(Command):
 class shell(Command):
 	def execute(self):
 		line = parse(self.line)
-		if line.chunk(1)[0] == '-':
+		if line.chunk(1) and line.chunk(1)[0] == '-':
 			flags = line.chunk(1)[1:]
 			command = line.rest(2)
 		else:
@@ -122,7 +122,7 @@ class shell(Command):
 
 	def tab(self):
 		line = parse(self.line)
-		if line.chunk(1)[0] == '-':
+		if line.chunk(1) and line.chunk(1)[0] == '-':
 			flags = line.chunk(1)[1:]
 			command = line.rest(2)
 		else:
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index 2efb059d..89bd4a3a 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -108,6 +108,7 @@ class Console(Widget):
 		self.focused = True
 		self.visible = True
 		self.line = string
+		self.history_search_pattern = self.line
 		self.pos = len(string)
 		if position is not None:
 			self.pos = min(self.pos, position)
@@ -174,7 +175,6 @@ class Console(Widget):
 
 		self.pos += len(key)
 		self.on_line_change()
-		self.history_search_pattern = self.line
 
 	def history_move(self, n):
 		try:
@@ -184,7 +184,10 @@ class Console(Widget):
 		else:
 			if self.line != current and self.line != self.history.top():
 				self.history.modify(self.line)
-			self.history.move(n, self.history_search_pattern)
+			if self.history_search_pattern:
+				self.history.search(self.history_search_pattern, n)
+			else:
+				self.history.move(n)
 			current = self.history.current()
 			if self.line != current:
 				self.line = self.history.current()
@@ -192,8 +195,7 @@ class Console(Widget):
 
 	def add_to_history(self):
 		self.history.fast_forward()
-		self.history.modify(self.line)
-		self.history.unique()
+		self.history.modify(self.line, unique=True)
 
 	def move(self, **keywords):
 		direction = Direction(keywords)
@@ -313,6 +315,7 @@ class Console(Widget):
 			self.on_line_change()
 
 	def on_line_change(self):
+		self.history_search_pattern = self.line
 		try:
 			cls = self._get_cmd_class()
 		except (KeyError, ValueError, IndexError):