@@ -5,7 +5,6 @@ import cc.unitmesh.devti.gui.chat.ChatActionType
5
5
import cc.unitmesh.devti.gui.sendToChatPanel
6
6
import cc.unitmesh.devti.intentions.AbstractChatIntention
7
7
import cc.unitmesh.devti.provider.ContextPrompter
8
- import cc.unitmesh.devti.provider.builtin.DefaultContextPrompter
9
8
import com.intellij.openapi.editor.Editor
10
9
import com.intellij.openapi.project.Project
11
10
import com.intellij.openapi.util.NlsSafe
@@ -29,24 +28,26 @@ class CustomIntention(private val intentionConfig: CustomIntentionConfig) : Abst
29
28
val withRange = elementWithRange(editor, file, project) ? : return
30
29
val selectedText = withRange.first
31
30
val psiElement = withRange.second
32
- val prompt: CustomIntentionPrompt = buildCustomPrompt(psiElement!! , selectedText, intentionConfig )
31
+ val prompt: CustomIntentionPrompt = buildCustomPrompt(psiElement!! , selectedText)
33
32
34
- sendToChatPanel(project, getActionType(), object : ContextPrompter () {
35
- override fun displayPrompt (): String {
36
- return prompt.displayPrompt
37
- }
33
+ if (intentionConfig.autoInvoke) {
34
+ sendToChatPanel(project, getActionType(), object : ContextPrompter () {
35
+ override fun displayPrompt (): String {
36
+ return prompt.displayPrompt
37
+ }
38
38
39
- override fun requestPrompt (): String {
40
- return prompt.requestPrompt
39
+ override fun requestPrompt (): String {
40
+ return prompt.requestPrompt
41
+ }
42
+ })
43
+ } else {
44
+ sendToChatPanel(project) { panel, _ ->
45
+ panel.setInput(prompt.displayPrompt)
41
46
}
42
- })
47
+ }
43
48
}
44
49
45
- private fun buildCustomPrompt (
46
- psiElement : PsiElement ,
47
- selectedText : @NlsSafe String ,
48
- config : CustomIntentionConfig ,
49
- ): CustomIntentionPrompt {
50
+ private fun buildCustomPrompt (psiElement : PsiElement , selectedText : @NlsSafe String ): CustomIntentionPrompt {
50
51
val stringBuilderWriter = StringWriter ()
51
52
val velocityContext = VelocityContext ()
52
53
0 commit comments