Skip to content

Commit 5cc8913

Browse files
committed
fix: map braces to previously found one
1 parent c8da5f8 commit 5cc8913

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/main/kotlin/com/github/tempest/framework/views/injection/PHPLanguageInjector.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ class PHPLanguageInjector : MultiHostInjector {
4949
}
5050
}
5151

52+
val tagsMap = mapOf(
53+
"{!!" to "!!}",
54+
"{{" to "}}",
55+
)
5256
private fun injectIntoText(
5357
element: PsiLanguageInjectionHost,
5458
registrar: MultiHostRegistrar
@@ -58,8 +62,8 @@ class PHPLanguageInjector : MultiHostInjector {
5862
.apply { if (size < 2) return }
5963

6064
// println("children: $children")
61-
val openTag = children.firstOrNull()?.psi ?: return
62-
val closeTag = children.lastOrNull()?.psi
65+
val openTag = children.find { it.text == "{!!" || it.text == "{{" }?.psi ?: return
66+
val closeTag = children.find { it.text == tagsMap[openTag.text] }?.psi
6367

6468
// println("openTag: ${openTag.text}, closeTag: ${closeTag?.text}")
6569
if ((openTag.text == "{!!" && closeTag?.text == "!!}") || (openTag.text == "{{" && closeTag?.text == "}}")) {

0 commit comments

Comments
 (0)