Skip to content

Commit a04b71b

Browse files
committed
Shorten diff content for deleted files in commit message prompt
1 parent 1ab30c3 commit a04b71b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • packages/vscode/src/views/panel/backend/message-handlers/handle-commit-changes/utils

packages/vscode/src/views/panel/backend/message-handlers/handle-commit-changes/utils/prompt-utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,17 @@ export const build_commit_message_prompt = (
4343
? new_path_line.substring('+++ b/'.length)
4444
: undefined
4545

46+
let final_diff_content = full_file_diff
47+
4648
let file_path: string | undefined
4749

4850
if (new_path && new_path != '/dev/null') {
4951
file_path = new_path
5052
} else if (old_path && old_path != '/dev/null') {
5153
file_path = old_path
54+
// Shorten diff of a deleted file
55+
const split_diff = full_file_diff.split('+++ /dev/null')
56+
final_diff_content = split_diff[0] + '+++ /dev/null'
5257
}
5358

5459
if (file_path) {
@@ -59,7 +64,7 @@ export const build_commit_message_prompt = (
5964
if (file_data) {
6065
changes_content += `The original state of the file for reference:\n\n<![CDATA[\n${file_data.content}\n]]>\n\n`
6166
}
62-
changes_content += `**New changes:**\n\n<![CDATA[\n${full_file_diff}\n]]>\n`
67+
changes_content += `**New changes:**\n\n<![CDATA[\n${final_diff_content}\n]]>\n`
6368
}
6469
}
6570

0 commit comments

Comments
 (0)