From c5e3e25dc79f230c53e8a6dca1478c1e7b855229 Mon Sep 17 00:00:00 2001 From: Blarc Date: Sat, 27 Jan 2024 17:34:31 +0100 Subject: [PATCH] fix(prompts): before and after are swapped in preview Closes: #119 --- CHANGELOG.md | 3 +++ .../github/blarc/ai/commits/intellij/plugin/AICommitAction.kt | 2 +- .../github/blarc/ai/commits/intellij/plugin/AICommitsUtils.kt | 3 ++- .../ai/commits/intellij/plugin/settings/prompt/PromptTable.kt | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e28a743..fba5220 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## [Unreleased] +### Fixed +- Diff "before" and "after" is swapped in "Edit Prompt" settings window. + ## [1.5.0] - 2023-12-26 ### Added diff --git a/src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitAction.kt b/src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitAction.kt index 212cb40..fdbedc2 100644 --- a/src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitAction.kt +++ b/src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitAction.kt @@ -33,7 +33,7 @@ class AICommitAction : AnAction(), DumbAware { val commitMessage = VcsDataKeys.COMMIT_MESSAGE_CONTROL.getData(e.dataContext) runBackgroundableTask(message("action.background"), project) { - val diff = computeDiff(includedChanges, project) + val diff = computeDiff(includedChanges, false, project) if (diff.isBlank()) { sendNotification(Notification.emptyDiff()) return@runBackgroundableTask diff --git a/src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitsUtils.kt b/src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitsUtils.kt index d20b84a..302473c 100644 --- a/src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitsUtils.kt +++ b/src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitsUtils.kt @@ -60,6 +60,7 @@ object AICommitsUtils { fun computeDiff( includedChanges: List, + reversePatch: Boolean, project: Project ): String { @@ -89,7 +90,7 @@ object AICommitsUtils { val filePatches = IdeaTextPatchBuilder.buildPatch( project, changes, - repository.root.toNioPath(), false, true + repository.root.toNioPath(), reversePatch, true ) val stringWriter = StringWriter() diff --git a/src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/settings/prompt/PromptTable.kt b/src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/settings/prompt/PromptTable.kt index aff3b18..aeb7256 100644 --- a/src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/settings/prompt/PromptTable.kt +++ b/src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/settings/prompt/PromptTable.kt @@ -145,7 +145,7 @@ class PromptTable { .toList() branch = commonBranch(changes, project) - diff = computeDiff(changes, project) + diff = computeDiff(changes, true, project) setPreview(prompt.content) }