Skip to content

Commit 1269b48

Browse files
committed
refactor(completion): adjust caret movement and input size
- Modify caret movement logic in `CustomAgentCompletion` to insert a space and move caret by one character. - Set preferred height of input field in `AutoDevInputSection` to
1 parent ccbe3e2 commit 1269b48

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
155155
}
156156
customRag.selectedItem = defaultRag
157157

158+
input.preferredSize = Dimension(input.preferredSize.width, 48)
158159
layoutPanel.addToLeft(customRag)
159160
}
160161

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/completion/provider/CustomAgentCompletion.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.intellij.codeInsight.completion.CompletionProvider
88
import com.intellij.codeInsight.completion.CompletionResultSet
99
import com.intellij.codeInsight.lookup.LookupElementBuilder
1010
import com.intellij.util.ProcessingContext
11+
import kotlinx.html.dom.document
1112

1213
class CustomAgentCompletion : CompletionProvider<CompletionParameters>() {
1314
override fun addCompletions(
@@ -17,11 +18,11 @@ class CustomAgentCompletion : CompletionProvider<CompletionParameters>() {
1718
) {
1819
val configs: List<CustomAgentConfig> = CustomAgentConfig.loadFromProject(parameters.originalFile.project)
1920
configs.forEach { config ->
20-
result.addElement(LookupElementBuilder.create(config.name)
21+
result.addElement(
22+
LookupElementBuilder.create(config.name)
2123
.withInsertHandler { context, _ ->
22-
context.editor.caretModel.moveCaretRelatively(
23-
1 + config.name.length, 0, false, false, false
24-
)
24+
context.document.insertString(context.tailOffset, " ")
25+
context.editor.caretModel.moveCaretRelatively(1, 0, false, true, false)
2526

2627
val toolWindow = AutoDevToolWindowFactory.getToolWindow(context.project)
2728
toolWindow?.contentManager?.contents?.map { it.component }?.forEach {

0 commit comments

Comments
 (0)