zsh completion: Eliminate common prefix when completing file names

This commit is contained in:
Kovid Goyal 2018-09-06 09:46:04 +05:30
parent d4fc0af7de
commit b45161ecc3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -108,6 +108,10 @@ def zsh_output_serializer(ans):
cmd += ['-S', '""']
if description in ans.files_groups:
cmd.append('-f')
common_prefix = os.path.commonprefix(tuple(matches))
if common_prefix:
cmd.extend(('-p', shlex.quote(common_prefix)))
matches = {k[len(common_prefix):]: v for k, v in matches.items()}
cmd.append('--')
for word, description in matches.items():
cmd.append(shlex.quote(word))