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**


Discussion:
codecov-commenter: # [Codecov](https://codecov.io/gh/xonsh/xonsh/pull/4400?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xonsh) Report
> Merging [#4400](https://codecov.io/gh/xonsh/xonsh/pull/4400?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xonsh) (4603254) into [main](https://codecov.io/gh/xonsh/xonsh/commit/65913462438ffe869efabd2ec5f7137ef85efaef?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xonsh) (6591346) will **increase** coverage by `0.00%`.
> The diff coverage is `50.00%`.

[![Impacted file tree graph](https://codecov.io/gh/xonsh/xonsh/pull/4400/graphs/tree.svg?width=650&height=150&src=pr&token=GXLt8EOk8Z&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xonsh)](https://codecov.io/gh/xonsh/xonsh/pull/4400?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xonsh)

```diff
@@           Coverage Diff           @@
##             main    #4400   +/-   ##
=======================================
  Coverage   57.70%   57.70%           
=======================================
  Files         138      138           
  Lines       22194    22194           
  Branches     4073     4073           
=======================================
+ Hits        12806    12808    +2     
+ Misses       8313     8312    -1     
+ Partials     1075     1074    -1     
```


| [Impacted Files](https://codecov.io/gh/xonsh/xonsh/pull/4400?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xonsh) | Coverage Δ | |
|---|---|---|
| [xontrib/jedi.py](https://codecov.io/gh/xonsh/xonsh/pull/4400/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xonsh#diff-eG9udHJpYi9qZWRpLnB5) | `82.55% <50.00%> (ø)` | |
| [xonsh/procs/pipelines.py](https://codecov.io/gh/xonsh/xonsh/pull/4400/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xonsh#diff-eG9uc2gvcHJvY3MvcGlwZWxpbmVzLnB5) | `78.75% <0.00%> (+0.38%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/xonsh/xonsh/pull/4400?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xonsh).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xonsh)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/xonsh/xonsh/pull/4400?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xonsh). Last update [6591346...4603254](https://codecov.io/gh/xonsh/xonsh/pull/4400?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xonsh). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xonsh).

jnoortheen: It is working now. 

Thanks for the update!

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 (