summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-11 21:45:46 +0200
committerhut <hut@lavabit.com>2010-04-11 21:46:00 +0200
commita9481b26a4c33daff7750aadfc6738bd9630f866 (patch)
tree43b0b7a91e265d0156e36464480d55b392b88036 /ranger
parent44a28601f4e1ab857e75ee4a48f45464f2ff3eff (diff)
downloadranger-a9481b26a4c33daff7750aadfc6738bd9630f866.tar.gz
Fixed little tab completion bug
Thanks to litemotiv for pointing it out
Diffstat (limited to 'ranger')
-rw-r--r--ranger/defaults/commands.py8
-rw-r--r--ranger/ext/command_parser.py21
2 files changed, 25 insertions, 4 deletions
diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py
index 4b2d1c8f..e69dcf90 100644
--- a/ranger/defaults/commands.py
+++ b/ranger/defaults/commands.py
@@ -79,11 +79,11 @@ class Command(FileManagerAware):
 
 			# one result. since it must be a directory, append a slash.
 			if len(dirnames) == 1:
-				return line + join(rel_dirname, dirnames[0]) + '/'
+				return line.start(1) + join(rel_dirname, dirnames[0]) + '/'
 
 			# more than one result. append no slash, so the user can
 			# manually type in the slash to advance into that directory
-			return (line + join(rel_dirname, dirname) for dirname in dirnames)
+			return (line.start(1) + join(rel_dirname, dirname) for dirname in dirnames)
 
 	def _tab_directory_content(self):
 		from os.path import dirname, basename, expanduser, join, isdir
@@ -129,11 +129,11 @@ class Command(FileManagerAware):
 
 			# one result. since it must be a directory, append a slash.
 			if len(names) == 1:
-				return line + join(rel_dirname, names[0]) + '/'
+				return line.start(1) + join(rel_dirname, names[0]) + '/'
 
 			# more than one result. append no slash, so the user can
 			# manually type in the slash to advance into that directory
-			return (line + join(rel_dirname, name) for name in names)
+			return (line.start(1) + join(rel_dirname, name) for name in names)
 
 
 # -------------------------------- definitions
diff --git a/ranger/ext/command_parser.py b/ranger/ext/command_parser.py
index 3a676e8f..d737c277 100644
--- a/ranger/ext/command_parser.py
+++ b/ranger/ext/command_parser.py
@@ -25,6 +25,7 @@ class LazyParser(object):
 		self._setting_line = None
 		self._rests_loaded = 0
 		self._rests_gen_instance = None
+		self._starts = None
 
 		try:
 			self.firstpart = line[:line.rindex(' ') + 1]
@@ -52,6 +53,26 @@ class LazyParser(object):
 		else:
 			return otherwise
 
+	def start(self, n):
+		if self._starts is None:
+			self._starts = ['']
+			line = self.line
+			result = ""
+			while True:
+				try:
+					index = line.index(' ') + 1
+				except:
+					break
+				if index == 1:
+					continue
+				result = line[:index]
+				self._starts.append(result)
+				line = line[index:]
+		try:
+			return self._starts[n]
+		except:
+			return self._starts[-1]
+
 	def _rest_generator(self):
 		lastrest = self.line
 		n = 0