diff --git a/jedi/parser/diff.py b/jedi/parser/diff.py index f97d6add..5842fcfb 100644 --- a/jedi/parser/diff.py +++ b/jedi/parser/diff.py @@ -437,11 +437,17 @@ class _NodesStackNode(object): def get_last_line(self, suffix): line = 0 if self.children_groups: - last_leaf = self.children_groups[-1].children[-1].get_last_leaf() + children_group = self.children_groups[-1] + last_leaf = children_group.children[-1].get_last_leaf() line = last_leaf.end_pos[0] # Calculate the line offsets - line += self.children_groups[-1].line_offset + offset = children_group.line_offset + if offset: + # In case the line_offset is not applied to this specific leaf, + # just ignore it. + if last_leaf.line <= children_group.last_line_offset_leaf.line: + line += children_group.line_offset # Newlines end on the next line, which means that they would cover # the next line. That line is not fully parsed at this point. diff --git a/test/test_parser/test_diff_parser.py b/test/test_parser/test_diff_parser.py index 3ba36c64..595bf9cc 100644 --- a/test/test_parser/test_diff_parser.py +++ b/test/test_parser/test_diff_parser.py @@ -488,12 +488,6 @@ def test_in_parentheses_newlines(differ): b = 2""") - script = jedi.Script(code1, line=2, column=8) - assert script.call_signatures() - script = jedi.Script(code2, line=2, column=9) - assert script.call_signatures() - script = jedi.Script(code1, line=2, column=8) - assert script.call_signatures() differ.initialize(code1) - differ.parse(code2, parsers=1, copies=1) - differ.parse(code1, parsers=1, copies=1) + differ.parse(code2, parsers=2, copies=1) + differ.parse(code1, parsers=2, copies=1)