commit | 851a7899004b5fc190446a4d4d50fba02c15e17c | [log] [tgz] |
---|---|---|
author | Patrizio <patrizio.gelosi@amarulasolutions.com> | Fri May 17 11:00:10 2024 +0200 |
committer | Patrizio <patrizio.gelosi@amarulasolutions.com> | Thu May 23 09:41:07 2024 +0200 |
tree | 8dd7605a733c94270fcbbd1006b631513e2cedf3 | |
parent | 6a1a3f7be66ad64d920a9687626bfe256f725712 [diff] |
Fix occasional inline code lookup issues: This commit addresses a problem where ChatGPT code snippets might not accurately be identified within a patch set's codebase. The issue typically arises when the patch set includes deletions at the beginning of files. Change-Id: I00fbde248ac5d218f13eea880f88740eeabfc900 Signed-off-by: Patrizio <patrizio.gelosi@amarulasolutions.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/patch/diff/FileDiffProcessed.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/patch/diff/FileDiffProcessed.java index 1ea641f..258503d 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/patch/diff/FileDiffProcessed.java +++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/patch/diff/FileDiffProcessed.java
@@ -101,7 +101,8 @@ } // If the lines modified in the PatchSet are deleted, they are mapped in charToLineMapItem to current lineNum else { - charToLineMapItem.put(content.length(), lineNum); + int startingPosition = charToLineMapItem.isEmpty() ? 0 : content.length(); + charToLineMapItem.put(startingPosition, lineNum); } if (config.getGptFullFileReview() || !diffType.equals("ab")) {