From a56221b4c53e348d74f0c9e83d6b71b8bb386f87 Mon Sep 17 00:00:00 2001 From: Maxime HAMM Date: Thu, 1 Apr 2021 10:47:18 +0200 Subject: [PATCH] Fix bug creation of settings folder should be done in write thread --- build.gradle | 2 +- .../kotlin/io/nimbly/tzatziki/config/Config.kt | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 643767e6..4b19fcff 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ plugins { allprojects { group = 'io.nimbly.tzatziki' - version '2.4.1' + version '2.4.2' } ext { diff --git a/plugin/src/main/kotlin/io/nimbly/tzatziki/config/Config.kt b/plugin/src/main/kotlin/io/nimbly/tzatziki/config/Config.kt index 908a5e1f..fb9b45d8 100644 --- a/plugin/src/main/kotlin/io/nimbly/tzatziki/config/Config.kt +++ b/plugin/src/main/kotlin/io/nimbly/tzatziki/config/Config.kt @@ -65,9 +65,7 @@ fun loadConfig(path: VirtualFile, project: Project): Config { var rootConfig = root.findChild(CONFIG_FOLDER) if (rootConfig == null) { - rootConfig = root.createChildDirectory(path, CONFIG_FOLDER) - rootConfig.copyDefaultsToFolder(project) - + rootConfig = root.copyDefaultsToFolder(path, project) project.notification("Configuration files were created") { PsiManager.getInstance(project).findDirectory(rootConfig)?.navigate(true) } @@ -162,13 +160,15 @@ private fun findRootCustomPropertiesFile(origin: PsiElement): PropertiesFile? = ?.getFile(origin.project) ?.let { if (it is PropertiesFile) it else null} -private fun VirtualFile.copyDefaultsToFolder(project: Project) { - WriteCommandAction.runWriteCommandAction(project) { +private fun VirtualFile.copyDefaultsToFolder(path: VirtualFile, project: Project): VirtualFile { + return WriteCommandAction.runWriteCommandAction(project) { + val dir = createChildDirectory(path, CONFIG_FOLDER) ALL_DEFAULTS .forEach { - if (findChild(it) == null) - addFrom(it) - } + if (dir.findChild(it) == null) + dir.addFrom(it) + } + return@runWriteCommandAction dir } }