Fix jedi path completion (#4400)

* xontrib: jedi: Don't complete paths with '~'

* tests: xontrib: jedi: Update tests

* news: Add fix-jedi-path-completion
This commit is contained in:
Daniel Shimon 2021-07-29 10:02:25 +03:00 committed by GitHub
parent 6591346243
commit 8dac83a9a0
Failed to generate hash of commit
3 changed files with 26 additions and 2 deletions

View file

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

View file

@ -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 (

View file

@ -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()