@@ -5,7 +5,6 @@ import cc.unitmesh.devti.gui.chat.ChatActionType
55import cc.unitmesh.devti.gui.sendToChatPanel
66import cc.unitmesh.devti.intentions.AbstractChatIntention
77import cc.unitmesh.devti.provider.ContextPrompter
8- import cc.unitmesh.devti.provider.builtin.DefaultContextPrompter
98import com.intellij.openapi.editor.Editor
109import com.intellij.openapi.project.Project
1110import com.intellij.openapi.util.NlsSafe
@@ -29,24 +28,26 @@ class CustomIntention(private val intentionConfig: CustomIntentionConfig) : Abst
2928 val withRange = elementWithRange(editor, file, project) ? : return
3029 val selectedText = withRange.first
3130 val psiElement = withRange.second
32- val prompt: CustomIntentionPrompt = buildCustomPrompt(psiElement!! , selectedText, intentionConfig )
31+ val prompt: CustomIntentionPrompt = buildCustomPrompt(psiElement!! , selectedText)
3332
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+ }
3838
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)
4146 }
42- })
47+ }
4348 }
4449
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 {
5051 val stringBuilderWriter = StringWriter ()
5152 val velocityContext = VelocityContext ()
5253
0 commit comments