summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--TODO2
-rw-r--r--ranger/gui/widgets/console.py17
2 files changed, 11 insertions, 8 deletions
diff --git a/TODO b/TODO
index 8549caba..0c89142b 100644
--- a/TODO
+++ b/TODO
@@ -28,7 +28,7 @@ General
    (X) #34  10/01/09  display free disk space
    (X) #35  10/01/09  display disk usage of files in current directory
    ( ) #36  10/01/11  help coloring is terribly inefficient
-   ( ) #37  10/01/13  better tab completion for OpenConsole
+   (X) #37  10/01/13  better tab completion for OpenConsole
    ( ) #38  10/01/16  searching in pager
    (X) #39  10/01/17  flushinput not always good
    (X) #42  10/01/17  memorize directory for `` when using :cd
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index b3e49c47..b30b30b0 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -388,15 +388,18 @@ class OpenConsole(ConsoleWithTab):
 		self.close()
 
 	def _get_tab(self):
-		# for now, just add " %s"
-		if ' ' in self.line:
-			result = self.line
-			if result and result[-1] != ' ':
-				result += ' '
-			return result + '%s '
-		else:
+		try:
+			position_of_last_space = self.line.rindex(" ")
+		except ValueError:
 			return (program + ' ' for program in self.fm.executables \
 					if program.startswith(self.line))
+		if position_of_last_space == len(self.line) - 1:
+			return self.line + '%s '
+		else:
+			before_word, start_of_word = self.line.rsplit(' ', 1)
+			return (before_word + ' ' + file.basename \
+					for file in self.fm.env.pwd.files \
+					if file.basename.startswith(start_of_word))
 
 	def _substitute_metachars(self, command):
 		dct = {}
51'>151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254