Repository: xonsh/xonsh

Issue:
bare path completion
<!--- 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: https://xon.sh/bash_to_xsh.html
If you don't find an answer there, please do open an issue! -->

## xonfig

<details>

```
+------------------+----------------------+
| xonsh            | 0.9.27               |
| Git SHA          | bc3b4962             |
| Commit Date      | Jun 11 12:27:29 2021 |
| Python           | 3.9.5                |
| PLY              | 3.11                 |
| have readline    | True                 |
| prompt toolkit   | 3.0.19               |
| shell type       | prompt_toolkit       |
| history backend  | sqlite               |
| pygments         | 2.9.0                |
| on posix         | True                 |
| on linux         | True                 |
| distro           | manjaro              |
| on wsl           | False                |
| on darwin        | False                |
| on windows       | False                |
| on cygwin        | False                |
| on msys2         | False                |
| is superuser     | False                |
| default encoding | utf-8                |
| xonsh encoding   | utf-8                |
| encoding errors  | surrogateescape      |
| on jupyter       | False                |
| jupyter kernel   | None                 |
| xontrib 1        | abbrevs              |
| xontrib 2        | argcomplete          |
| xontrib 3        | avox_poetry          |
| xontrib 4        | back2dir             |
| xontrib 5        | broot                |
| xontrib 6        | cmd_done             |
| xontrib 7        | commands             |
| xontrib 8        | fzf-widgets          |
| xontrib 9        | hist_navigator       |
| xontrib 10       | jedi                 |
| xontrib 11       | powerline3           |
| xontrib 12       | prompt_ret_code      |
| xontrib 13       | vox                  |
| xontrib 14       | voxapi               |
+------------------+----------------------+

```

</details>

## Expected Behavior
<!--- Tell us what should happen -->
upon typing just the path, xonsh `cd` into that. auto-completion for this is not working.
![image](https://user-images.githubusercontent.com/6702219/124352483-f35c3200-dc1d-11eb-98d0-b779d2775ca7.png)


## 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` -->

![image](https://user-images.githubusercontent.com/6702219/124352420-b42de100-dc1d-11eb-807e-973fe98c8496.png)


### Traceback (if applicable)

<details>

```
traceback
```

</details>

## Steps to Reproduce
<!--- Please try to write out a minimal reproducible snippet to trigger the bug, it will help us fix it! -->

## For community
⬇️  **Please click the 👍 reaction instead of leaving a `+1` or 👍  comment**


Comments:

Patch:
diff --git a/news/fix-jedi-path-completion.rst b/news/fix-jedi-path-completion.rst
new file mode 100644
index 00000000..8757b89d
--- /dev/null
+++ b/news/fix-jedi-path-completion.rst
@@ -0,0 +1,23 @@
+**Added:**
+
+* <news item>
+
+**Changed:**
+
+* <news item>
+
+**Deprecated:**
+
+* <news item>
+
+**Removed:**
+
+* <news item>
+
+**Fixed:**
+
+* ``Jedi`` completer doesn't complete paths with ``~``.
+
+**Security:**
+
+* <news item>
diff --git a/xontrib/jedi.py b/xontrib/jedi.py
index 1d860b82..49d99138 100644
--- a/xontrib/jedi.py
+++ b/xontrib/jedi.py
@@ -65,8 +65,8 @@ def complete_jedi(context: CompletionContext):
 
     # if we're completing a possible command and the prefix contains a valid path, don't complete.
     if context.command:
-        path_parts = os.path.split(context.command.prefix)
-        if len(path_parts) > 1 and os.path.isdir(os.path.join(*path_parts[:-1])):
+        path_dir = os.path.dirname(context.command.prefix)
+        if path_dir and os.path.isdir(os.path.expanduser(path_dir)):
             return None
 
     filter_func = get_filter_function()


Test patch:
diff --git a/tests/xontribs/test_jedi.py b/tests/xontribs/test_jedi.py
index 0681e7fb..166ef200 100644
--- a/tests/xontribs/test_jedi.py
+++ b/tests/xontribs/test_jedi.py
@@ -253,6 +253,7 @@ def test_special_tokens(jedi_xontrib):
 @skip_if_on_windows
 def test_no_command_path_completion(jedi_xontrib, completion_context_parse):
     assert jedi_xontrib.complete_jedi(completion_context_parse("./", 2)) is None
+    assert jedi_xontrib.complete_jedi(completion_context_parse("~/", 2)) is None
     assert jedi_xontrib.complete_jedi(completion_context_parse("./e", 3)) is None
     assert jedi_xontrib.complete_jedi(completion_context_parse("/usr/bin/", 9)) is None
     assert (