From 43f62750ac51b237344baca59086f2bc3bff5ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Langa?= Date: Tue, 11 Feb 2025 06:16:43 +0100 Subject: [PATCH] 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 --- news/subprocess-completions-dir-spaces.rst | 27 ++++++++++++++++++++++ xonsh/completers/tools.py | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 news/subprocess-completions-dir-spaces.rst diff --git a/news/subprocess-completions-dir-spaces.rst b/news/subprocess-completions-dir-spaces.rst new file mode 100644 index 000000000..eebb28791 --- /dev/null +++ b/news/subprocess-completions-dir-spaces.rst @@ -0,0 +1,27 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* Subprocess-based completions like + `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:** + +* diff --git a/xonsh/completers/tools.py b/xonsh/completers/tools.py index 48ddeb908..cdb369bd2 100644 --- a/xonsh/completers/tools.py +++ b/xonsh/completers/tools.py @@ -275,7 +275,7 @@ def complete_from_sub_proc(*args: str, sep=None, filter_prefix=None, **env_vars: lines = output.split(sep) # 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: if filter_prefix and (not filter_func(line, filter_prefix)): continue