Simplify getting code for completions.

This commit is contained in:
Dave Halter
2017-09-03 00:11:23 +02:00
parent fc8326bca1
commit e85816cc85
+1 -7
View File
@@ -93,19 +93,13 @@ def _get_code_for_stack(code_lines, module_node, position):
# Error leafs cannot be parsed, completion in strings is also # Error leafs cannot be parsed, completion in strings is also
# impossible. # impossible.
raise OnErrorLeaf(leaf) raise OnErrorLeaf(leaf)
else:
if leaf == ';':
user_stmt = leaf.parent
else: else:
user_stmt = leaf user_stmt = leaf
while True: while True:
if user_stmt.parent.type in ('file_input', 'suite'): if user_stmt.parent.type in ('file_input', 'suite', 'simple_stmt'):
break break
user_stmt = user_stmt.parent user_stmt = user_stmt.parent
if user_stmt.parent.type == 'simple_stmt':
user_stmt = user_stmt.parent
if is_after_newline: if is_after_newline:
if user_stmt.start_pos[1] > position[1]: if user_stmt.start_pos[1] > position[1]:
# This means that it's actually a dedent and that means that we # This means that it's actually a dedent and that means that we