Skip to content

Commit 25083eb

Browse files
authored
Merge pull request #36 from elm-tooling/fix-33-expose
Fix IDE crash on expose
2 parents 30174f5 + c90cefa commit 25083eb

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/kotlin/org/elm/ide/intentions/ElmAtCaretIntentionActionBase.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ abstract class ElmAtCaretIntentionActionBase<Ctx> : BaseElementAtCaretIntentionA
4141

4242
abstract fun invoke(project: Project, editor: Editor, context: Ctx)
4343

44+
override fun startInWriteAction(): Boolean = true
45+
4446
final override fun invoke(project: Project, editor: Editor, element: PsiElement) {
4547
val context = findApplicableContext(project, editor, element) ?: return
4648
checkWriteAccessAllowed()
@@ -51,4 +53,4 @@ abstract class ElmAtCaretIntentionActionBase<Ctx> : BaseElementAtCaretIntentionA
5153
checkReadAccessAllowed()
5254
return findApplicableContext(project, editor, element) != null
5355
}
54-
}
56+
}

src/main/kotlin/org/elm/openapiext/Utils.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.intellij.openapi.vfs.VirtualFile
2121
import com.intellij.openapi.vfs.VirtualFileManager
2222
import com.intellij.psi.PsiFile
2323
import com.intellij.psi.PsiManager
24+
import com.intellij.codeInsight.intention.preview.IntentionPreviewUtils
2425
import org.jdom.Element
2526
import org.jdom.input.SAXBuilder
2627
import java.nio.file.Path
@@ -38,6 +39,9 @@ val Project.modules: Collection<Module>
3839

3940

4041
fun checkWriteAccessAllowed() {
42+
// In preview we must not assert write access; the platform runs without it.
43+
if (IntentionPreviewUtils.isIntentionPreviewActive()) return
44+
4145
check(ApplicationManager.getApplication().isWriteAccessAllowed) {
4246
"Needs write action"
4347
}

0 commit comments

Comments
 (0)