From 1014cd81d984ab6801d6a8debc0d5056a2b63643 Mon Sep 17 00:00:00 2001 From: e859127 <149989533+e859127@users.noreply.github.com> Date: Tue, 20 Aug 2024 03:34:02 +0000 Subject: [PATCH] Fix issue in parser when calculating line numbers with non-empty section header --- unidiff/patch.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/unidiff/patch.py b/unidiff/patch.py index bee28fc..ece5506 100644 --- a/unidiff/patch.py +++ b/unidiff/patch.py @@ -278,6 +278,9 @@ def _parse_hunk(self, header, diff, encoding, metadata_only): target_line_no = hunk.target_start expected_source_end = source_line_no + hunk.source_length expected_target_end = target_line_no + hunk.target_length + if hunk.section_header: + expected_source_end -= 1 + expected_target_end -= 1 added = 0 removed = 0