mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
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:
parent
6591346243
commit
8dac83a9a0
3 changed files with 26 additions and 2 deletions
23
news/fix-jedi-path-completion.rst
Normal file
23
news/fix-jedi-path-completion.rst
Normal 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>
|
|
@ -253,6 +253,7 @@ def test_special_tokens(jedi_xontrib):
|
||||||
@skip_if_on_windows
|
@skip_if_on_windows
|
||||||
def test_no_command_path_completion(jedi_xontrib, completion_context_parse):
|
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("~/", 2)) is None
|
||||||
assert jedi_xontrib.complete_jedi(completion_context_parse("./e", 3)) 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 jedi_xontrib.complete_jedi(completion_context_parse("/usr/bin/", 9)) is None
|
||||||
assert (
|
assert (
|
||||||
|
|
|
@ -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 we're completing a possible command and the prefix contains a valid path, don't complete.
|
||||||
if context.command:
|
if context.command:
|
||||||
path_parts = os.path.split(context.command.prefix)
|
path_dir = os.path.dirname(context.command.prefix)
|
||||||
if len(path_parts) > 1 and os.path.isdir(os.path.join(*path_parts[:-1])):
|
if path_dir and os.path.isdir(os.path.expanduser(path_dir)):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
filter_func = get_filter_function()
|
filter_func = get_filter_function()
|
||||||
|
|
Loading…
Add table
Reference in a new issue