Skip to content

Commit 421a511

Browse files
authored
Merge branch 'main' into TestGen-114
2 parents 5676ae4 + 18590f8 commit 421a511

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Enable syntax highlighting when viewing diff for /test"
4+
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/controller/CodeTestChatController.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,10 @@ class CodeTestChatController(
457457
when (message.actionID) {
458458
"utg_view_diff" -> {
459459
withContext(EDT) {
460+
// virtual file only needed for syntax highlighting when viewing diff
461+
val tempPath = Files.createTempFile(null, ".${session.testFileName.substringAfterLast('.')}")
462+
val virtualFile = tempPath.toFile().toVirtualFile()
463+
460464
(DiffManager.getInstance() as DiffManagerEx).showDiffBuiltin(
461465
context.project,
462466
SimpleDiffRequest(
@@ -465,13 +469,18 @@ class CodeTestChatController(
465469
getFileContentAtTestFilePath(
466470
session.projectRoot,
467471
session.testFileRelativePathToProjectRoot
468-
)
472+
),
473+
virtualFile
474+
),
475+
DiffContentFactory.getInstance().create(
476+
session.generatedTestDiffs.values.first(),
477+
virtualFile
469478
),
470-
DiffContentFactory.getInstance().create(session.generatedTestDiffs.values.first()),
471479
"Before",
472480
"After"
473481
)
474482
)
483+
Files.deleteIfExists(tempPath)
475484
session.openedDiffFile = FileEditorManager.getInstance(context.project).selectedEditor?.file
476485
ApplicationManager.getApplication().runReadAction {
477486
generatedFileContent = getGeneratedFileContent(session)

0 commit comments

Comments
 (0)