Repository: xonsh/xonsh

Issue:
Bash completion is badly broken on master
<!--- Provide a general summary of the issue in the Title above -->
<!--- If you have a question along the lines of "How do I do this Bash command in xonsh"
please first look over the Bash to Xonsh translation guide: http://xon.sh/bash_to_xsh.html
If you don't find an answer there, please do open an issue! -->
Changes to py-bash-completion are having some unexpected side-effects that we need to fix before a release

## xonfig
<!--- Please post the output of the `xonfig` command (run from inside xonsh) so we know more about your current setup -->
```
+------------------+---------------------+
| xonsh            | 0.7.10.dev63        |
| Git SHA          | 2286a598            |
| Commit Date      | Oct 2 08:54:29 2018 |
| Python           | 3.6.5               |
| PLY              | 3.11                |
| have readline    | True                |
| prompt toolkit   | 2.0.5               |
| shell type       | prompt_toolkit2     |
| pygments         | 2.2.0               |
| on posix         | True                |
| on linux         | False               |
| on darwin        | True                |
| on windows       | False               |
| on cygwin        | False               |
| on msys2         | False               |
| is superuser     | False               |
| default encoding | utf-8               |
| xonsh encoding   | utf-8               |
| encoding errors  | surrogateescape     |
+------------------+---------------------+
```

## Expected Behavior
<!--- Tell us what should happen -->
In a directory with one file `test.xsh`, pressing tab at `vim te` should expand to `vim test.xsh`

## Current Behavior
<!--- Tell us what happens instead of the expected behavior -->
<!--- If part of your bug report is a traceback, please first enter debug mode before triggering the error
To enter debug mode, set the environment variable `XONSH_DEBUG=1` _before_ starting `xonsh`.  
On Linux and OSX, an easy way to to do this is to run `env XONSH_DEBUG=1 xonsh` -->

```
tmp/cleandir 88e2064 $ ls
test.xsh

tmp/cleandir 88e2064 $ vim te<TAB>

Unhandled exception in event loop:
  File "/home/gil/miniconda3/lib/python3.6/site-packages/prompt_toolkit/eventloop/coroutine.py", line 90, in step_next
    new_f = coroutine.throw(exc)
  File "/home/gil/miniconda3/lib/python3.6/site-packages/prompt_toolkit/buffer.py", line 1637, in new_coroutine
    yield From(coroutine(*a, **kw))
  File "/home/gil/miniconda3/lib/python3.6/site-packages/prompt_toolkit/eventloop/coroutine.py", line 90, in step_next
    new_f = coroutine.throw(exc)
  File "/home/gil/miniconda3/lib/python3.6/site-packages/prompt_toolkit/buffer.py", line 1495, in async_completer
    cancel=lambda: not proceed()))
  File "/home/gil/miniconda3/lib/python3.6/site-packages/prompt_toolkit/eventloop/coroutine.py", line 86, in step_next
    new_f = coroutine.send(None)
  File "/home/gil/miniconda3/lib/python3.6/site-packages/prompt_toolkit/eventloop/async_generator.py", line 114, in consume_async_generator
    item = iterator.send(send)
  File "/home/gil/miniconda3/lib/python3.6/site-packages/prompt_toolkit/completion/base.py", line 166, in get_completions_async
    for item in self.get_completions(document, complete_event):
  File "/home/gil/miniconda3/lib/python3.6/site-packages/xonsh/ptk2/completer.py", line 45, in get_completions
    prefix, line_ex, begidx + expand_offset, endidx + expand_offset, self.ctx
  File "/home/gil/miniconda3/lib/python3.6/site-packages/xonsh/completer.py", line 36, in complete
    out = func(prefix, line, begidx, endidx, ctx)
  File "/home/gil/miniconda3/lib/python3.6/site-packages/xonsh/completers/bash.py", line 22, in complete_from_bash
    quote_paths=_quote_paths,
  File "/home/gil/miniconda3/lib/python3.6/site-packages/xonsh/completers/bash_completion.py", line 377, in bash_completions
    if commprefix[strip_len] == strip_prefix[strip_len]:

Exception string index out of range
Press ENTER to continue...
```

## Steps to Reproduce
<!--- Please try to write out a minimal reproducible snippet to trigger the bug, it will help us fix it! -->

```
mkdir empty_dir 
cd empty_dir
touch test.xsh
vim te<TAB>
```


Discussion:
Temporary workaround for those on the bleeding edge is to `completer remove bash`
Fix incoming

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
@@ -373,7 +373,7 @@ def bash_completions(
     commprefix = os.path.commonprefix(list(out))
     strip_len = 0
     strip_prefix = prefix.strip("\"'")
-    while strip_len < len(prefix):
+    while strip_len < len(strip_prefix):
         if commprefix[strip_len] == strip_prefix[strip_len]:
             break
         strip_len += 1


Test patch: