Repository: xonsh/xonsh

Issue:
Autocomplete doesn't understand multi-space in name of a file
xonsh autocomplete can't understand multi-space (more than one space) in name of a file and consider it as one space the following gif will show it: [bug gif](https://ibb.co/eVno7x)  


Discussion:
Hi @riwogo -- thanks for reporting!  Yep, that's definitely a bug.
I think this may technically be a bug in https://github.com/xonsh/py-bash-completion
Potential fix is in https://github.com/xonsh/py-bash-completion/pull/4

Resolving patch:
diff --git a/xonsh/completers/bash_completion.py b/xonsh/completers/bash_completion.py
--- a/xonsh/completers/bash_completion.py
+++ b/xonsh/completers/bash_completion.py
@@ -2,6 +2,8 @@
 from bash.
 """
 # developer note: this file should not perform any action on import.
+#                 This file comes from https://github.com/xonsh/py-bash-completion
+#                 and should be edited there!
 import os
 import re
 import sys
@@ -237,7 +239,7 @@ def _bash_quote_paths(paths, start, end):
 COMP_CWORD={n}
 $_func {cmd} {prefix} {prev}
 
-for ((i=0;i<${{#COMPREPLY[*]}};i++)) do echo ${{COMPREPLY[i]}}; done
+for ((i=0;i<${{#COMPREPLY[*]}};i++)) do echo "${{COMPREPLY[i]}}"; done
 """
 
 
@@ -274,8 +276,8 @@ def bash_completions(prefix, line, begidx, endidx, env=None, paths=None,
 
     Returns
     -------
-    rtn : list of str
-        Possible completions of prefix, sorted alphabetically.
+    rtn : set of str
+        Possible completions of prefix
     lprefix : int
         Length of the prefix to be replaced in the completion.
     """
@@ -340,3 +342,60 @@ def bash_completions(prefix, line, begidx, endidx, env=None, paths=None,
         out = set([x.rstrip() for x in out])
 
     return out, len(prefix) - strip_len
+
+
+def bash_complete_line(line, return_line=True, **kwargs):
+    """Provides the completion from the end of the line.
+
+    Parameters
+    ----------
+    line : str
+        Line to complete
+    return_line : bool, optional
+        If true (default), will return the entire line, with the completion added.
+        If false, this will instead return the strings to append to the original line.
+    kwargs : optional
+        All other keyword arguments are passed to the bash_completions() function.
+
+    Returns
+    -------
+    rtn : set of str
+        Possible completions of prefix
+    """
+    # set up for completing from the end of the line
+    split = line.split()
+    if len(split) > 1 and not line.endswith(' '):
+        prefix = split[-1]
+        begidx = len(line.rsplit(prefix)[0])
+    else:
+        prefix = ''
+        begidx = len(line)
+    endidx = len(line)
+    # get completions
+    out, lprefix = bash_completions(prefix, line, begidx, endidx, **kwargs)
+    # reformat output
+    if return_line:
+        preline = line[:-lprefix]
+        rtn = {preline + o for o in out}
+    else:
+        rtn = {o[lprefix:] for o in out}
+    return rtn
+
+
+def _bc_main(args=None):
+    """Runs complete_line() and prints the output."""
+    from argparse import ArgumentParser
+    p = ArgumentParser('bash_completions')
+    p.add_argument('--return-line', action='store_true', dest='return_line', default=True,
+                   help='will return the entire line, with the completion added')
+    p.add_argument('--no-return-line', action='store_false', dest='return_line',
+                   help='will instead return the strings to append to the original line')
+    p.add_argument('line', help='line to complete')
+    ns = p.parse_args(args=args)
+    out = bash_complete_line(ns.line, return_line=ns.return_line)
+    for o in sorted(out):
+        print(o)
+
+
+if __name__ == '__main__':
+    _bc_main()


Test patch: