fix zsh serialization of directory candidates ending with /

This commit is contained in:
Kovid Goyal 2022-08-09 14:51:14 +05:30
parent 33a3e3fb61
commit 6860f7ffd6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -277,8 +277,8 @@ def zsh_output_serializer(ans: Completions) -> str:
allm = tuple(matches) allm = tuple(matches)
if len(allm) > 1: if len(allm) > 1:
common_prefix = os.path.commonprefix(allm) common_prefix = os.path.commonprefix(allm)
if common_prefix and '/' in common_prefix: if common_prefix and os.sep in common_prefix:
common_prefix = os.path.dirname(common_prefix) + '/' common_prefix = os.path.dirname(common_prefix).rstrip(os.sep) + os.sep
cmd.extend(('-p', shlex.quote(common_prefix))) cmd.extend(('-p', shlex.quote(common_prefix)))
matches = MatchGroup({k[len(common_prefix):]: v for k, v in matches.items()}) matches = MatchGroup({k[len(common_prefix):]: v for k, v in matches.items()})
has_descriptions = any(matches.values()) has_descriptions = any(matches.values())