Skip to content

Commit 1a02563

Browse files
committed
fix(command): ensure file insertion executes on the EDT for thread safety #259
1 parent 022c9f5 commit 1a02563

File tree

1 file changed

+6
-2
lines changed
  • exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec

1 file changed

+6
-2
lines changed

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/WriteInsCommand.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ class WriteInsCommand(val myProject: Project, val argument: String, val content:
3939
val psiFile = PsiManager.getInstance(myProject).findFile(virtualFile)
4040
?: return "$DEVINS_ERROR: File not found: $argument"
4141

42-
FileEditorManager.getInstance(myProject).openFile(virtualFile, true)
43-
return executeInsert(psiFile, range, content)
42+
var output: String? = null
43+
runInEdt {
44+
FileEditorManager.getInstance(myProject).openFile(virtualFile, true)
45+
output = executeInsert(psiFile, range, content)
46+
}
47+
return output
4448
}
4549

4650
private fun writeToFile(filepath: String, projectDir: VirtualFile): String {

0 commit comments

Comments
 (0)