SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
Fix(tools): Avoid shrinking the viewport
Kilian Lieret2190cf21faa8
diff --git a/tools/edit_anthropic/bin/str_replace_editor b/tools/edit_anthropic/bin/str_replace_editorindex d579842e..d47255dc 100644--- a/tools/edit_anthropic/bin/str_replace_editor+++ b/tools/edit_anthropic/bin/str_replace_editor@@ -132,10 +132,7 @@ class WindowExpander:if i_line + direction in iter_lines:next_line = lines[i_line + direction - 1]score = 0- if line == "" and i_line != current_line:- # Need to exclude current line, because we're gonna choose the- # 'previous' line as actual breakpoint, which might actually shrink- # the viewport otherwise.+ if line == "":score = 1if next_line == "":# Double new blank line:@@ -160,6 +157,9 @@ class WindowExpander:# print(f"Score {score} for line {i_line} ({line})")# print(f"Best score {best_score} for line {best_breakpoint} ({lines[best_breakpoint-1]})")+ if direction == 1 and best_breakpoint < current_line or direction == -1 and best_breakpoint > current_line:+ # We don't want to shrink the view port, so we return the current line+ return current_linereturn best_breakpoint