Skip to content

Commit c5e3e25

Browse files
committed
fix(prompts): before and after are swapped in preview
Closes: #119
1 parent be0550d commit c5e3e25

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## [Unreleased]
44

5+
### Fixed
6+
- Diff "before" and "after" is swapped in "Edit Prompt" settings window.
7+
58
## [1.5.0] - 2023-12-26
69

710
### Added

src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AICommitAction : AnAction(), DumbAware {
3333
val commitMessage = VcsDataKeys.COMMIT_MESSAGE_CONTROL.getData(e.dataContext)
3434

3535
runBackgroundableTask(message("action.background"), project) {
36-
val diff = computeDiff(includedChanges, project)
36+
val diff = computeDiff(includedChanges, false, project)
3737
if (diff.isBlank()) {
3838
sendNotification(Notification.emptyDiff())
3939
return@runBackgroundableTask

src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitsUtils.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ object AICommitsUtils {
6060

6161
fun computeDiff(
6262
includedChanges: List<Change>,
63+
reversePatch: Boolean,
6364
project: Project
6465
): String {
6566

@@ -89,7 +90,7 @@ object AICommitsUtils {
8990
val filePatches = IdeaTextPatchBuilder.buildPatch(
9091
project,
9192
changes,
92-
repository.root.toNioPath(), false, true
93+
repository.root.toNioPath(), reversePatch, true
9394
)
9495

9596
val stringWriter = StringWriter()

src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/settings/prompt/PromptTable.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class PromptTable {
145145
.toList()
146146

147147
branch = commonBranch(changes, project)
148-
diff = computeDiff(changes, project)
148+
diff = computeDiff(changes, true, project)
149149
setPreview(prompt.content)
150150
}
151151

0 commit comments

Comments
 (0)