Skip to content

Commit b1411c1

Browse files
committed
perf(devti): optimize code application in DiffRepair
- Remove unnecessary ApplicationManager invocation - Streamline code execution within runWriteAction - Improve readability and performance when updating editor document
1 parent 2ce2e76 commit b1411c1

File tree

1 file changed

+5
-7
lines changed
  • core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/patch

1 file changed

+5
-7
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/patch/DiffRepair.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ object DiffRepair {
2424
val flow = LlmFactory.create(project, ModelType.FastApply).stream(prompt, "You are professional program", false)
2525

2626
processStreamRealtime(project, flow) { code ->
27-
ApplicationManager.getApplication().invokeLater({
28-
runWriteAction {
29-
editor.document.setText(code)
30-
}
31-
}, ModalityState.defaultModalityState())
27+
runWriteAction {
28+
editor.document.setText(code)
29+
}
3230
}
3331
}
3432

@@ -59,7 +57,7 @@ object DiffRepair {
5957
AutoDevCoroutineScope.Companion.scope(project).launch {
6058
val suggestion = StringBuilder()
6159
var lastProcessedCode = ""
62-
60+
6361
flow.cancellable().collect { char ->
6462
suggestion.append(char)
6563
val code = CodeFence.Companion.parse(suggestion.toString())
@@ -75,7 +73,7 @@ object DiffRepair {
7573
AutoDevCoroutineScope.Companion.scope(project).launch {
7674
val suggestion = StringBuilder()
7775
var lastProcessedCode = ""
78-
76+
7977
flow.cancellable().collect { char ->
8078
suggestion.append(char)
8179
val code = CodeFence.Companion.parse(suggestion.toString())

0 commit comments

Comments
 (0)