Skip to content

Commit

Permalink
fix: live templates in multiple projects
Browse files Browse the repository at this point in the history
  • Loading branch information
popovanton0 committed May 18, 2024
1 parent 812e0ea commit c94c19f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ internal object AddLiveTemplates {
}
}

fun execute(config: KelpConfig) {
fun execute(config: KelpConfig, projectName: String) {
val templates = config.liveTemplates.orEmpty()
val templateSettings = TemplateSettings.getInstance()
templateSettings.templates.forEach {
if (it.groupName == "Kelp") templateSettings.removeTemplate(it)
if (it.groupName == "Kelp ($projectName)") templateSettings.removeTemplate(it)
}
templates.forEach { template ->
TemplateImpl(
/* key = */ template.abbreviation,
/* string = */ template.text,
/* group = */ "Kelp"
/* group = */ "Kelp ($projectName)"
).apply {
template.description?.let { description = it }
addVariable("CODE_COMPLETION", "complete()", "", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private class KelpConfigService(private val project: Project) : Disposable {
?.readText()

data = json.decodeFromString<KelpConfig>(configText ?: return@runReadAction)
AddLiveTemplates.execute(data!!)
AddLiveTemplates.execute(data!!, project.name)
if (!isFirstRun) reloadNotification()
}
}.onFailure {
Expand Down

0 comments on commit c94c19f

Please sign in to comment.