Fix tilde expansion for fileglob
Use common suffix to determine what part of original term to keep and how much of the full path to combine to get a usable filename.pull/4420/head
parent
57e51f7fdf
commit
89e73c123f
|
@ -31,7 +31,11 @@ class LookupModule(object):
|
||||||
for term in terms:
|
for term in terms:
|
||||||
dwimterms = utils.path_dwim(self.basedir, term)
|
dwimterms = utils.path_dwim(self.basedir, term)
|
||||||
# This skips whatever prefix the dwim added, leaving just the filename for the item
|
# This skips whatever prefix the dwim added, leaving just the filename for the item
|
||||||
dwim_prefix_len = len(dwimterms) - len(term)
|
i = -1
|
||||||
ret.extend([ f[dwim_prefix_len:]
|
while dwimterms[i] == term[i] and -i < len(term) and -i < len(dwimterms):
|
||||||
|
i = i - 1
|
||||||
|
orig_prefix_len = i + 1
|
||||||
|
dwim_prefix_len = len(dwimterms) + i + 1
|
||||||
|
ret.extend([ term[:orig_prefix_len] + f[dwim_prefix_len:]
|
||||||
for f in glob.glob(dwimterms) if os.path.isfile(f) ])
|
for f in glob.glob(dwimterms) if os.path.isfile(f) ])
|
||||||
return ret
|
return ret
|
||||||
|
|
Loading…
Reference in New Issue