From 3eef0a4ebd3eec130fa3da53f854499cbc83e84a Mon Sep 17 00:00:00 2001 From: "Hussam.lawen" Date: Thu, 15 Feb 2024 22:21:58 +0200 Subject: [PATCH] fix line selection, don't support line deletions --- pr_agent/algo/git_patch_processing.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pr_agent/algo/git_patch_processing.py b/pr_agent/algo/git_patch_processing.py index d7d7a7e4..383d488f 100644 --- a/pr_agent/algo/git_patch_processing.py +++ b/pr_agent/algo/git_patch_processing.py @@ -266,7 +266,7 @@ def extract_hunk_lines_from_patch(patch: str, file_name, line_start, line_end, s skip_hunk = False selected_lines_num = 0 header_line = line - patch_with_lines_str += f'\n{header_line}\n' + match = RE_HUNK_HEADER.match(line) res = list(match.groups()) @@ -289,6 +289,7 @@ def extract_hunk_lines_from_patch(patch: str, file_name, line_start, line_end, s if not (start2 <= line_start <= start2 + size2): skip_hunk = True continue + patch_with_lines_str += f'\n{header_line}\n' elif not skip_hunk: if side.lower() == 'right' and line_start <= start2 + selected_lines_num <= line_end: @@ -296,6 +297,7 @@ def extract_hunk_lines_from_patch(patch: str, file_name, line_start, line_end, s if side.lower() == 'left' and start1 <= selected_lines_num + start1 <= line_end: selected_lines += line + '\n' patch_with_lines_str += line + '\n' - selected_lines_num += 1 + if not line.startswith('-'): # currently we don't support /ask line for deleted lines + selected_lines_num += 1 return patch_with_lines_str.rstrip(), selected_lines.rstrip() \ No newline at end of file