1
0
forked from VimPlug/jedi

Imports completions after a semicolon work now

This commit is contained in:
Dave Halter
2019-06-02 17:54:00 +02:00
parent c6173efe61
commit 1213b51c66
2 changed files with 12 additions and 1 deletions

View File

@@ -179,7 +179,12 @@ class Completion:
nonterminals = [stack_node.nonterminal for stack_node in stack]
nodes = [node for stack_node in stack for node in stack_node.nodes]
nodes = []
for stack_node in stack:
if stack_node.dfa.from_rule == 'small_stmt':
nodes = []
else:
nodes += stack_node.nodes
if nodes and nodes[-1] in ('as', 'def', 'class'):
# No completions for ``with x as foo`` and ``import x as foo``.

View File

@@ -456,3 +456,9 @@ def test_import_needed_modules_by_jedi(Script, environment, tmpdir, name):
module, = script.goto_definitions()
assert module._evaluator.builtins_module.py__file__() != module_path
assert module._evaluator.typing_module.py__file__() != module_path
def test_import_with_semicolon(Script):
names = [c.name for c in Script('xzy; from abc import ').completions()]
assert 'ABCMeta' in names
assert 'abc' not in names