Skip to content

Commit ef477c5

Browse files
committed
Bugfix for PatchAnalyer LLM patch handling
1 parent 4ac0aee commit ef477c5

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/main/java/gin/PatchAnalyser.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,24 @@ private static Patch parsePatch(String patchText, SourceFileLine sourceFileLine,
101101
cleanPatch = patchText.replaceFirst("\\|", "").trim();
102102
}
103103

104-
String[] editStrings = cleanPatch.trim().split("\\| (?=gin).+"); // only count separators with "gin" following then (i.e. the start of a new edit)
104+
String[] editStrings = cleanPatch.trim().split("\\|\\s+(?=gin\\.)"); // only count separators with "gin" following then (i.e. the start of a new edit)
105105

106106
boolean allLineEdits = true;
107107
boolean allStatementEdits = true;
108108

109109
for (String editString : editStrings) {
110110

111-
String[] tokens = editString.trim().split("\\s+");
111+
editString = editString.trim();
112112

113+
if (editString.isEmpty() || editString.equals("|")) {
114+
continue;
115+
}
116+
117+
if (editString.startsWith("|")) {
118+
editString = editString.substring(1).trim();
119+
}
120+
121+
String[] tokens = editString.split("\\s+", 2);
113122
String editAction = tokens[0];
114123

115124
Class<?> clazz = null;

0 commit comments

Comments
 (0)