forked from VimPlug/jedi
Fix the fast parser issue #589.
This commit is contained in:
@@ -424,14 +424,12 @@ class FastParser(use_metaclass(CachedFastParser)):
|
||||
"""
|
||||
Side effect: Alters the list of nodes.
|
||||
"""
|
||||
indent = len(source) - len(source.lstrip('\t '))
|
||||
self.current_node = self.current_node.parent_until_indent(indent)
|
||||
|
||||
h = hash(source)
|
||||
for index, node in enumerate(nodes):
|
||||
if node.hash == h and node.source == source:
|
||||
node.reset_node()
|
||||
nodes.remove(node)
|
||||
parser_code = source
|
||||
break
|
||||
else:
|
||||
tokenizer = FastTokenizer(parser_code)
|
||||
@@ -444,6 +442,9 @@ class FastParser(use_metaclass(CachedFastParser)):
|
||||
|
||||
node = ParserNode(self.module, p, code_part_actually_used)
|
||||
|
||||
indent = len(parser_code) - len(parser_code.lstrip('\t '))
|
||||
self.current_node = self.current_node.parent_until_indent(indent)
|
||||
|
||||
self.current_node.add_node(node, line_offset)
|
||||
return node
|
||||
|
||||
|
||||
@@ -447,11 +447,14 @@ def test_decorator_string_issue():
|
||||
"""
|
||||
Test case from #589
|
||||
"""
|
||||
s = jedi.Script(dedent('''\
|
||||
source = dedent('''\
|
||||
"""
|
||||
@"""
|
||||
def bla():
|
||||
pass
|
||||
|
||||
bla.'''))
|
||||
bla.''')
|
||||
|
||||
s = jedi.Script(source)
|
||||
assert s.completions()
|
||||
assert s._parser.module().get_code() == source
|
||||
|
||||
Reference in New Issue
Block a user