fix: disable submission when current response is ongoing

This commit is contained in:
Carl-Robert Linnupuu 2024-12-06 10:03:35 +00:00
parent dc8dcb1564
commit 71dd9463c4
2 changed files with 10 additions and 9 deletions

View file

@ -65,12 +65,18 @@ class PromptTextField(
IdeEventQueue.getInstance().addDispatcher(
PromptTextFieldEventDispatcher(this, suggestionsPopupManager, appliedInlays) {
onSubmit(text, appliedInlays)
clear()
},
this
)
}
fun clear() {
runInEdt {
text = ""
clearInlays()
}
}
fun addInlayElement(actionPrefix: String, text: String?, actionItem: SuggestionActionItem?) {
editor?.let {
var startOffset = it.document.text.lastIndexOf(AT_CHAR)
@ -150,13 +156,6 @@ class PromptTextField(
clear()
}
private fun clear() {
runInEdt {
text = ""
clearInlays()
}
}
private fun clearInlays() {
runUndoTransparentWriteAction {
appliedInlays.forEach { it.inlay.dispose() }

View file

@ -62,6 +62,7 @@ class UserInputPanel(
) {
override fun actionPerformed(e: AnActionEvent) {
handleSubmit(promptTextField.text)
promptTextField.clear()
}
}
)
@ -134,8 +135,9 @@ class UserInputPanel(
override fun getInsets(): Insets = JBUI.insets(4)
private fun handleSubmit(text: String, appliedInlays: List<AppliedActionInlay>? = emptyList()) {
if (text.isNotEmpty()) {
if (text.isNotEmpty() && submitButton.isEnabled) {
onSubmit(text, appliedInlays)
promptTextField.clear()
}
}