diff options
author | hut <hut@lavabit.com> | 2010-04-12 18:21:10 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-12 18:21:10 +0200 |
commit | 854c529e090bb61b886e1334af8c4aad096038dd (patch) | |
tree | 89c2cc192070f70c6ebc7582507fc446b712e626 | |
parent | 1019737b2570cebd09a2cdff29642085aa6d062e (diff) | |
parent | a9481b26a4c33daff7750aadfc6738bd9630f866 (diff) | |
download | ranger-854c529e090bb61b886e1334af8c4aad096038dd.tar.gz |
Merge branch 'master' of ssh://repo.or.cz/srv/git/ranger
-rw-r--r-- | ranger/defaults/commands.py | 8 | ||||
-rw-r--r-- | ranger/ext/command_parser.py | 21 |
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 |