@@ -25,6 +25,7 @@ import com.intellij.openapi.wm.IdeFocusManager
25
25
import com.intellij.psi.PsiElement
26
26
import com.intellij.psi.PsiFile
27
27
import cc.unitmesh.devti.inlay.InlayPanel
28
+ import cc.unitmesh.devti.inline.EscHandler
28
29
import java.awt.event.ActionEvent
29
30
import javax.swing.AbstractAction
30
31
@@ -33,6 +34,10 @@ import javax.swing.AbstractAction
33
34
* user can input custom text to call with LLM.
34
35
*/
35
36
open class QuickAssistantAction : AnAction () {
37
+
38
+ private var currentInlayPanel: InlayPanel <QuickPromptField >? = null
39
+ private var escHandler: EscHandler ? = null
40
+
36
41
init {
37
42
presentationText(" settings.autodev.others.quickAssistant" , templatePresentation)
38
43
}
@@ -101,7 +106,15 @@ open class QuickAssistantAction : AnAction() {
101
106
}
102
107
103
108
private fun useInlayMode (editor : Editor , offset : Int , project : Project , element : PsiElement ? ) {
104
- InlayPanel .add(editor as EditorEx , offset, QuickPromptField ())?.let {
109
+ currentInlayPanel?.let {
110
+ Disposer .dispose(it.inlay!! )
111
+ }
112
+ escHandler = EscHandler (editor) {
113
+ Disposer .dispose(currentInlayPanel?.inlay!! )
114
+ escHandler?.dispose()
115
+ }
116
+ currentInlayPanel = InlayPanel .add(editor as EditorEx , offset, QuickPromptField ())?.also {
117
+ currentInlayPanel = null
105
118
doExecute(it, project, editor, element)
106
119
}
107
120
}
0 commit comments