Skip to content

Commit

Permalink
Fix bug creation of settings folder should be done in write thread
Browse files Browse the repository at this point in the history
  • Loading branch information
maximehamm committed Apr 1, 2021
1 parent 464e2db commit a56221b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {

allprojects {
group = 'io.nimbly.tzatziki'
version '2.4.1'
version '2.4.2'
}

ext {
Expand Down
16 changes: 8 additions & 8 deletions plugin/src/main/kotlin/io/nimbly/tzatziki/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href='PROP'>files</a> were created") {
PsiManager.getInstance(project).findDirectory(rootConfig)?.navigate(true)
}
Expand Down Expand Up @@ -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<VirtualFile>(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
}
}

Expand Down

0 comments on commit a56221b

Please sign in to comment.