Skip to content

Commit e1da93e

Browse files
committed
feat(interaction): add support for ReplaceSelection prompt type
- Added `ReplaceSelection` prompt type to the `InteractionType` enum. - Modified `CustomActionPrompt.kt` to include logic for handling `ReplaceSelection` prompts. - Updated documentation in `team-prompts.md` and `variables.md`.
1 parent f552e0d commit e1da93e

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

docs/customize/team-prompts.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ interaction type:
4848
- ChatPanel, the prompt will be inserted in the chat panel
4949
- OutputFile, the prompt will be inserted in the output file, `output-{timestamp}.{extension}`, the extension will be
5050
parsed from the result's language.
51+
- ReplaceSelection, the prompt will replace the current selection (since [email protected])
5152

5253
## English Examples
5354

docs/customize/variables.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,23 @@ permalink: /customize/variables
3737

3838
use `@context.methodName()` to call the method.
3939

40-
```
40+
```kotlin
4141
interface TeamContextProvider {
4242
/**
4343
* Retrieves the code of the target file associated with the given test name.
4444
*
45-
* @param fileName the name of the test
45+
* @param methodName the name of the test
4646
* @return the code of the target file as a string
4747
*/
48-
fun underTestFileCode(fileName: String): String
48+
fun underTestFileCode(methodName: String): String
49+
50+
/**
51+
* Retrieves the code of the target method associated with the given test name.
52+
*
53+
* @param methodName the name of the test for which to retrieve the target method code
54+
* @return the code of the target method as a string
55+
*/
56+
fun underTestMethodCode(methodName: String): String
4957

5058
/**
5159
* Returns a list of similar chunks.
@@ -66,4 +74,4 @@ interface TeamContextProvider {
6674
*/
6775
fun relatedCode(): String
6876
}
69-
```
77+
```

src/main/kotlin/cc/unitmesh/devti/custom/team/CustomActionPrompt.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,3 @@ data class CustomActionPrompt(
120120
}
121121
}
122122

123-
enum class InteractionType {
124-
ChatPanel,
125-
AppendCursor,
126-
AppendCursorStream,
127-
OutputFile,
128-
Replace
129-
;
130-
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package cc.unitmesh.devti.custom.team
2+
3+
enum class InteractionType {
4+
ChatPanel,
5+
AppendCursor,
6+
AppendCursorStream,
7+
OutputFile,
8+
ReplaceSelection
9+
;
10+
}

src/main/kotlin/cc/unitmesh/devti/custom/team/TeamPromptExecTask.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import cc.unitmesh.devti.gui.chat.ChatActionType
77
import cc.unitmesh.devti.gui.sendToChatWindow
88
import cc.unitmesh.devti.intentions.action.task.BaseCompletionTask
99
import cc.unitmesh.devti.intentions.action.task.CodeCompletionRequest
10-
import com.intellij.openapi.application.invokeLater
1110
import com.intellij.openapi.application.runReadAction
12-
import com.intellij.openapi.application.runWriteAction
1311
import com.intellij.openapi.editor.Editor
1412
import com.intellij.openapi.progress.ProgressIndicator
1513
import com.intellij.openapi.progress.ProgressManager
@@ -75,7 +73,7 @@ class TeamPromptExecTask(
7573
.runProcessWithProgressAsynchronously(task, BackgroundableProcessIndicator(task))
7674
}
7775

78-
InteractionType.Replace -> {
76+
InteractionType.ReplaceSelection -> {
7977
val msgString = systemPrompt + "\n" + userPrompt
8078
val request = runReadAction {
8179
CodeCompletionRequest.create(editor, offset, element, null, msgString, isReplacement = true)

0 commit comments

Comments
 (0)