Skip to content

Commit

Permalink
Fix #2376 Error when generating event listeners in read only file
Browse files Browse the repository at this point in the history
  • Loading branch information
RedNesto committed Sep 28, 2024
1 parent 864ed93 commit dcf7e99
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.demonwav.mcdev.util.mapFirstNotNull
import com.intellij.codeInsight.CodeInsightActionHandler
import com.intellij.ide.util.TreeClassChooserFactory
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.EditorModificationUtil
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiFile
Expand All @@ -43,6 +44,10 @@ class GenerateEventListenerHandler : CodeInsightActionHandler {
val caretElement = file.findElementAt(editor.caretModel.offset) ?: return
val context = caretElement.context ?: return

if (!EditorModificationUtil.requestWriting(editor)) {
return
}

val chooser = TreeClassChooserFactory.getInstance(project)
.createWithInnerClassesScopeChooser(
RefactoringBundle.message("choose.destination.class"),
Expand Down

0 comments on commit dcf7e99

Please sign in to comment.