The diff parser was slighly off with prefixes, fixes #1121

This commit is contained in:
Dave Halter
2018-05-20 19:13:08 +02:00
parent ac0bf4fcdd
commit c2eacdb81c
2 changed files with 8 additions and 2 deletions

View File

@@ -490,6 +490,9 @@ class _NodesStack(object):
new_tos = tos
for node in nodes:
if node.start_pos[0] > until_line:
break
if node.type == 'endmarker':
# We basically removed the endmarker, but we are not allowed to
# remove the newline at the end of the line, otherwise it's
@@ -501,8 +504,6 @@ class _NodesStack(object):
# Endmarkers just distort all the checks below. Remove them.
break
if node.start_pos[0] > until_line:
break
# TODO this check might take a bit of time for large files. We
# might want to change this to do more intelligent guessing or
# binary search.

View File

@@ -502,3 +502,8 @@ def test_endmarker_newline(differ):
differ.initialize(code1)
differ.parse(code2, parsers=2, copies=2, expect_error_leaves=True)
def test_newlines_at_end(differ):
differ.initialize('a\n\n')
differ.parse('a\n', copies=1)