Don't append a space if the single available completion ends with a directory separator (#5792)

* Don't append a space if the single available completion ends with a directory separator

* Update subprocess-completions-dir-spaces.rst

---------

Co-authored-by: Andy Kipp <anki-code@users.noreply.github.com>
This commit is contained in:
Łukasz Langa 2025-02-11 06:16:43 +01:00 committed by GitHub
parent a33ccdf636
commit 43f62750ac
Failed to generate hash of commit
2 changed files with 28 additions and 1 deletions

View file

@ -0,0 +1,27 @@
**Added:**
* <news item>
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* Subprocess-based completions like
`xontrib-fish-completer <https://github.com/xonsh/xontrib-fish-completer>`_
no longer append a space if the single available completion ends with
a directory separator. This is consistent with the behavior of the
default completer.
**Security:**
* <news item>

View file

@ -275,7 +275,7 @@ def complete_from_sub_proc(*args: str, sep=None, filter_prefix=None, **env_vars:
lines = output.split(sep) lines = output.split(sep)
# if there is a single completion candidate then maybe it is over # if there is a single completion candidate then maybe it is over
append_space = len(lines) == 1 append_space = len(lines) == 1 and not lines[0].rstrip().endswith(os.sep)
for line in lines: for line in lines:
if filter_prefix and (not filter_func(line, filter_prefix)): if filter_prefix and (not filter_func(line, filter_prefix)):
continue continue