Skip to content

Commit

Permalink
feat(devin-lang): improve code input handling #101
Browse files Browse the repository at this point in the history
The input handling in the chat coding panel has been refactored to use a more consistent approach when creating and displaying the popup. The creation of the popup is now centralized, and the visibility and disposal states are checked before showing or creating the popup. This change also ensures that the popup is not shown when the user inputs a dollar sign in the code input section, which was causing unexpected behavior. Additionally, the preferred size calculation for the chat coding panel has been adjusted to ensure a consistent minimum height.
  • Loading branch information
phodal committed Mar 12, 2024
1 parent f07f15f commit beb6f81
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
11 changes: 5 additions & 6 deletions src/main/kotlin/cc/unitmesh/devti/gui/chat/AutoDevInput.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,12 @@ class AutoDevInput(
}

fun recreateDocument() {
// val language = findLanguage("DevIn")
val language = findLanguage("Markdown")
val file =
LightVirtualFile("AutoDevInput-" + UUID.randomUUID(), language, "")
val language = findLanguage("DevIn")
// val language = findLanguage("Markdown")
val id = UUID.randomUUID()
val file = LightVirtualFile("AutoDevInput-$id", language, "")

val document =
file.findDocument() ?: throw IllegalStateException("Can't create in-memory document")
val document = file.findDocument() ?: throw IllegalStateException("Can't create in-memory document")

initializeDocumentListeners(document)
setDocument(document)
Expand Down
33 changes: 16 additions & 17 deletions src/main/kotlin/cc/unitmesh/devti/gui/chat/AutoDevInputSection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,22 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
revalidate()
}

if (event.newFragment.contentEquals("$")) {
if (popup == null) {
popup = createPopup()
}

if (popup?.isVisible == true) {
popup?.cancel()
}

if (popup?.isDisposed == true) {
popup = createPopup()
showPopupAbove(popup!!, this@AutoDevInputSection)
} else {
showPopupAbove(popup!!, this@AutoDevInputSection)
}
}
// if (event.newFragment.contentEquals("$")) {
// if (popup == null) {
// popup = createPopup()
// }
//
// if (popup?.isVisible == true) {
// popup?.cancel()
// }
//
// if (popup?.isDisposed == true) {
// popup = createPopup()
// showPopupAbove(popup!!, this@AutoDevInputSection)
// } else {
// showPopupAbove(popup!!, this@AutoDevInputSection)
// }
// }
}
}

Expand Down Expand Up @@ -261,7 +261,6 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
this.revalidate()
}


override fun getPreferredSize(): Dimension {
val result = super.getPreferredSize()
result.height = max(min(result.height, maxHeight), minimumSize.height)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class ChatCodingPanel(private val chatCodingService: ChatCodingService, val disp
override fun onSubmit(component: AutoDevInputSection, trigger: AutoDevInputTrigger) {
val prompt = component.text
component.text = ""

if (prompt.isEmpty()) {
return
}
Expand Down

0 comments on commit beb6f81

Please sign in to comment.