Skip to content

Commit

Permalink
fix(run-code): wrap scratch file deletion in runWriteAction
Browse files Browse the repository at this point in the history
Ensure thread safety by wrapping scratch file deletion in `runWriteAction` to prevent potential concurrency issues.
  • Loading branch information
phodal committed Jan 10, 2025
1 parent 0a87a6b commit 5271cd7
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.phodal.shirecore.sketch.highlight.toolbar
import com.intellij.ide.scratch.ScratchRootType
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.runWriteAction
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.project.DumbAwareAction
import com.intellij.openapi.vfs.readText
Expand Down Expand Up @@ -49,7 +50,9 @@ class ShireRunCodeAction : DumbAwareAction() {
psiFile,
)
} finally {
scratchFile.delete(this)
runWriteAction {
scratchFile.delete(this)
}
}
}
}

0 comments on commit 5271cd7

Please sign in to comment.