From a7b1e3fe7028bb999752f2bd996b8cd2b1d72ec3 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sun, 12 Mar 2017 15:58:14 +0100 Subject: [PATCH] Fixed another diff parser error. --- jedi/parser/diff.py | 10 ++++++++-- test/test_parser/test_diff_parser.py | 10 ++-------- 2 files changed, 10 insertions(+), 10 deletions(-) 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)