mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-09 22:25:53 +08:00
Fix diff parser: error dedents in between nodes should be ignored for now when copying
This commit is contained in:
@@ -617,6 +617,8 @@ class _NodesTree(object):
|
||||
# Endmarkers just distort all the checks below. Remove them.
|
||||
break
|
||||
|
||||
if node.type == 'error_leaf' and node.token_type == 'ERROR_DEDENT':
|
||||
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.
|
||||
|
||||
@@ -1148,3 +1148,28 @@ def test_dont_copy_error_leaves(differ):
|
||||
differ.initialize(code1)
|
||||
differ.parse(code2, parsers=1, expect_error_leaves=True)
|
||||
differ.parse(code1, parsers=2)
|
||||
|
||||
|
||||
def test_error_dedent_in_between(differ):
|
||||
code1 = dedent('''\
|
||||
class C:
|
||||
def f():
|
||||
a
|
||||
if something:
|
||||
x
|
||||
z
|
||||
''')
|
||||
code2 = dedent('''\
|
||||
class C:
|
||||
def f():
|
||||
a
|
||||
dedent
|
||||
if other_thing:
|
||||
b
|
||||
if something:
|
||||
x
|
||||
z
|
||||
''')
|
||||
differ.initialize(code1)
|
||||
differ.parse(code2, copies=1, parsers=1, expect_error_leaves=True)
|
||||
differ.parse(code1, parsers=2, copies=1)
|
||||
|
||||
Reference in New Issue
Block a user