Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions IPython/core/completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,18 +1371,18 @@ def _jedi_matches(self, cursor_column:int, cursor_line:int, text:str):
try_jedi = True

try:
# should we check the type of the node is Error ?
# find the first token in the current tree -- if it is a ' or " then we are in a string
completing_string = False
try:
# jedi < 0.11
from jedi.parser.tree import ErrorLeaf
except ImportError:
# jedi >= 0.11
from parso.tree import ErrorLeaf
first_child = next(c for c in interpreter._get_module().tree_node.children if hasattr(c, 'value'))
except StopIteration:
pass
else:
# note the value may be ', ", or it may also be ''' or """, or
# in some cases, """what/you/typed..., but all of these are
# strings.
completing_string = len(first_child.value) > 0 and first_child.value[0] in {"'", '"'}

next_to_last_tree = interpreter._get_module().tree_node.children[-2]
completing_string = False
if isinstance(next_to_last_tree, ErrorLeaf):
completing_string = next_to_last_tree.value.lstrip()[0] in {'"', "'"}
# if we are in a string jedi is likely not the right candidate for
# now. Skip it.
try_jedi = not completing_string
Expand Down