##// END OF EJS Templates
Improves detection of whether tab-completion is in a string and supresses Jedi....
Coon, Ethan T -
Show More
@@ -1371,18 +1371,18 b' class IPCompleter(Completer):'
1371 try_jedi = True
1371 try_jedi = True
1372
1372
1373 try:
1373 try:
1374 # should we check the type of the node is Error ?
1374 # find the first token in the current tree -- if it is a ' or " then we are in a string
1375 completing_string = False
1375 try:
1376 try:
1376 # jedi < 0.11
1377 first_child = next(c for c in interpreter._get_module().tree_node.children if hasattr(c, 'value'))
1377 from jedi.parser.tree import ErrorLeaf
1378 except StopIteration:
1378 except ImportError:
1379 pass
1379 # jedi >= 0.11
1380 else:
1380 from parso.tree import ErrorLeaf
1381 # note the value may be ', ", or it may also be ''' or """, or
1382 # in some cases, """what/you/typed..., but all of these are
1383 # strings.
1384 completing_string = len(first_child.value) > 0 and first_child.value[0] in {"'", '"'}
1381
1385
1382 next_to_last_tree = interpreter._get_module().tree_node.children[-2]
1383 completing_string = False
1384 if isinstance(next_to_last_tree, ErrorLeaf):
1385 completing_string = next_to_last_tree.value.lstrip()[0] in {'"', "'"}
1386 # if we are in a string jedi is likely not the right candidate for
1386 # if we are in a string jedi is likely not the right candidate for
1387 # now. Skip it.
1387 # now. Skip it.
1388 try_jedi = not completing_string
1388 try_jedi = not completing_string
General Comments 0
You need to be logged in to leave comments. Login now