diff --git a/images/resources/messages/ImagesBundle.properties b/images/resources/messages/ImagesBundle.properties index 471eb51e99cb..627d50c72869 100644 --- a/images/resources/messages/ImagesBundle.properties +++ b/images/resources/messages/ImagesBundle.properties @@ -1,5 +1,5 @@ error.title.launching.external.editor=Problem Launching External Executable -error.cannot.edit.image.external.editor=Can't edit image in external editor +error.cannot.edit.image.external.editor=Cannot edit image in an external editor select.external.executable.title=Select Editor select.external.executable.message=Select external graphics editor diff --git a/images/src/org/intellij/images/actions/EditExternallyAction.kt b/images/src/org/intellij/images/actions/EditExternallyAction.kt index 5a7e11c5d157..75ff4567decf 100644 --- a/images/src/org/intellij/images/actions/EditExternallyAction.kt +++ b/images/src/org/intellij/images/actions/EditExternallyAction.kt @@ -12,6 +12,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.actionSystem.PlatformCoreDataKeys import com.intellij.openapi.application.EDT import com.intellij.openapi.diagnostic.thisLogger +import com.intellij.openapi.progress.currentThreadCoroutineScope import com.intellij.openapi.project.DumbAwareAction import com.intellij.openapi.ui.Messages import com.intellij.openapi.util.Disposer @@ -117,7 +118,7 @@ internal class EditExternallyAction : DumbAwareAction() { private fun performActionWithBackingFile(e: AnActionEvent, imageFile: VirtualFile) { try { val disposable = e.getDisposable() - disposable.launch { + currentThreadCoroutineScope().launch { try { val backingFile = imageFile.copyToBackingFile(disposable) actionPerformed(e, backingFile) @@ -138,7 +139,7 @@ internal class EditExternallyAction : DumbAwareAction() { } private fun VirtualFile.copyToBackingFile(disposable: Disposable): VirtualFile { - val filePath = Files.createTempFile("EditExternallyAction", name) + val filePath = Files.createTempFile("EditExternallyAction (copy)", name) Disposer.register(disposable, Disposable { filePath.safeDelete() }) @@ -162,17 +163,6 @@ private fun Path.safeDelete() { } } -private fun Disposable.launch(block: suspend CoroutineScope.() -> Unit) { - val job = SupervisorJob() - @Suppress("SSBasedInspection") - CoroutineScope(job + Dispatchers.IO).launch { - block() - } - Disposer.register(this, Disposable { - job.cancel() - }) -} - /** * Tries to get a Disposable from the event *