Fix diff parser: Need to calculate the prefix for the diff tokenizer better

This commit is contained in:
Dave Halter
2019-01-13 22:38:53 +01:00
parent ea8a758051
commit 01dba7f8ce
2 changed files with 26 additions and 0 deletions

View File

@@ -388,6 +388,10 @@ class DiffParser(object):
typ, string, start_pos, prefix = next(tokens)
if '\n' in prefix or '\r' in prefix:
prefix = re.sub(r'[^\n\r]+\Z', '', prefix)
else:
assert start_pos[1] >= len(prefix), repr(prefix)
if start_pos[1] - len(prefix) == 0:
prefix = ''
yield PythonToken(
PythonTokenTypes.ENDMARKER, '',
(start_pos[0] + line_offset, 0),