mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 12:54:29 +08:00
The diff parser was slighly off with prefixes, fixes #1121
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user