Skip to content

Commit a3c1c03

Browse files
authored
fix(amazonq): skip edit suggestion if applyDiff fail (#7693)
## Problem applyDiff may fail and the consequence is the `newCode` to update become empty string, thus deleting all users' code. ## Before https://github.com/user-attachments/assets/6524bae2-1374-452d-bb4e-3ec6f865c258 ## After https://github.com/user-attachments/assets/75d5ed7a-6940-4432-a8d9-73c485afb2c3 ## Solution --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 3898ca2 commit a3c1c03

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/amazonq/src/app/inline/EditRendering/imageRenderer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ export async function showEdits(
2929
const { svgImage, startLine, newCode, origionalCodeHighlightRange } =
3030
await svgGenerationService.generateDiffSvg(currentFile, item.insertText as string)
3131

32+
// TODO: To investigate why it fails and patch [generateDiffSvg]
33+
if (newCode.length === 0) {
34+
getLogger('nextEditPrediction').warn('not able to apply provided edit suggestion, skip rendering')
35+
return
36+
}
37+
3238
if (svgImage) {
3339
// display the SVG image
3440
await displaySvgDecoration(

0 commit comments

Comments
 (0)