Skip to content

Commit beb6f81

Browse files
committed
feat(devin-lang): improve code input handling #101
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.
1 parent f07f15f commit beb6f81

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

src/main/kotlin/cc/unitmesh/devti/gui/chat/AutoDevInput.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,12 @@ class AutoDevInput(
137137
}
138138

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

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

148147
initializeDocumentListeners(document)
149148
setDocument(document)

src/main/kotlin/cc/unitmesh/devti/gui/chat/AutoDevInputSection.kt

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,22 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
109109
revalidate()
110110
}
111111

112-
if (event.newFragment.contentEquals("$")) {
113-
if (popup == null) {
114-
popup = createPopup()
115-
}
116-
117-
if (popup?.isVisible == true) {
118-
popup?.cancel()
119-
}
120-
121-
if (popup?.isDisposed == true) {
122-
popup = createPopup()
123-
showPopupAbove(popup!!, this@AutoDevInputSection)
124-
} else {
125-
showPopupAbove(popup!!, this@AutoDevInputSection)
126-
}
127-
}
112+
// if (event.newFragment.contentEquals("$")) {
113+
// if (popup == null) {
114+
// popup = createPopup()
115+
// }
116+
//
117+
// if (popup?.isVisible == true) {
118+
// popup?.cancel()
119+
// }
120+
//
121+
// if (popup?.isDisposed == true) {
122+
// popup = createPopup()
123+
// showPopupAbove(popup!!, this@AutoDevInputSection)
124+
// } else {
125+
// showPopupAbove(popup!!, this@AutoDevInputSection)
126+
// }
127+
// }
128128
}
129129
}
130130

@@ -261,7 +261,6 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
261261
this.revalidate()
262262
}
263263

264-
265264
override fun getPreferredSize(): Dimension {
266265
val result = super.getPreferredSize()
267266
result.height = max(min(result.height, maxHeight), minimumSize.height)

src/main/kotlin/cc/unitmesh/devti/gui/chat/ChatCodingPanel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class ChatCodingPanel(private val chatCodingService: ChatCodingService, val disp
9090
override fun onSubmit(component: AutoDevInputSection, trigger: AutoDevInputTrigger) {
9191
val prompt = component.text
9292
component.text = ""
93+
9394
if (prompt.isEmpty()) {
9495
return
9596
}

0 commit comments

Comments
 (0)