Skip to content

Commit

Permalink
refactor(diff): wrap document update in runWriteAction
Browse files Browse the repository at this point in the history
Ensure thread safety by wrapping document updates in `runWriteAction` to prevent potential UI thread issues.
  • Loading branch information
phodal committed Jan 19, 2025
1 parent 2411fb7 commit 777480b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import cc.unitmesh.devti.diff.model.streamDiff
import cc.unitmesh.devti.llms.LlmFactory
import cc.unitmesh.devti.util.AutoDevCoroutineScope
import cc.unitmesh.devti.util.parser.CodeFence
import com.intellij.openapi.application.runWriteAction
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.cancellable
import kotlinx.coroutines.flow.flowOf
Expand Down Expand Up @@ -99,7 +100,9 @@ class DiffStreamHandler(

fun acceptAll() {
resetState()
editor.document.setText(newCode)
runWriteAction {
editor.document.setText(newCode)
}
}

fun rejectAll() {
Expand Down

0 comments on commit 777480b

Please sign in to comment.