diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/script/configuration/listener/ScriptChangesNotifier.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/script/configuration/listener/ScriptChangesNotifier.kt index ca03ef56f65..043c4cf42e2 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/script/configuration/listener/ScriptChangesNotifier.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/script/configuration/listener/ScriptChangesNotifier.kt @@ -62,6 +62,11 @@ internal class ScriptChangesNotifier( val document = event.document val file = FileDocumentManager.getInstance().getFile(document)?.takeIf { it.isInLocalFileSystem } ?: return + // Do not listen for changes in files that are not open + if (file !in FileEditorManager.getInstance(project).openFiles) { + return + } + if (ApplicationManager.getApplication().isUnitTestMode) { getListener(project, file)?.documentChanged(file, updater) } else {