mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 21:04:29 +08:00
Fix diff parser get_last_line calculation
This commit is contained in:
@@ -447,6 +447,9 @@ class _NodesTreeNode(object):
|
||||
if suffix and not suffix.endswith('\n'):
|
||||
# This is the end of a file (that doesn't end with a newline).
|
||||
line += 1
|
||||
|
||||
if self._node_children:
|
||||
return max(line, self._node_children[-1].get_last_line(suffix))
|
||||
return line
|
||||
|
||||
|
||||
|
||||
@@ -579,3 +579,29 @@ def test_add_error_indentation(differ):
|
||||
code = 'if x:\n 1\n'
|
||||
differ.initialize(code)
|
||||
differ.parse(code + ' 2\n', parsers=1, copies=0, expect_error_leaves=True)
|
||||
|
||||
|
||||
def test_differing_docstrings(differ):
|
||||
code1 = dedent('''\
|
||||
def foobar(x, y):
|
||||
1
|
||||
return x
|
||||
|
||||
def bazbiz():
|
||||
foobar()
|
||||
lala
|
||||
''')
|
||||
|
||||
code2 = dedent('''\
|
||||
def foobar(x, y):
|
||||
2
|
||||
return x + y
|
||||
|
||||
def bazbiz():
|
||||
z = foobar()
|
||||
lala
|
||||
''')
|
||||
|
||||
differ.initialize(code1)
|
||||
differ.parse(code2, parsers=3, copies=1)
|
||||
differ.parse(code1, parsers=3, copies=1)
|
||||
|
||||
Reference in New Issue
Block a user