Skip to content

Commit 84c1aba

Browse files
committed
Fix #25. Add check for empty range list.
1 parent 62a7e2e commit 84c1aba

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/main/kotlin/com/intellij/StyledComponents/StyledComponentsInjector.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class StyledComponentsInjector : MultiHostInjector {
3838
val acceptedPattern = places.find { (elementPattern) -> elementPattern.accepts(injectionHost) }
3939
if (acceptedPattern != null) {
4040
val stringPlaces = getInjectionPlaces(injectionHost)
41+
if (stringPlaces.isEmpty())
42+
return
4143
registrar.startInjecting(LESSLanguage.INSTANCE)
4244
stringPlaces.forEachIndexed { index, (prefix, range, suffix) ->
4345
val thePrefix = if (index == 0) acceptedPattern.prefix + prefix.orEmpty() else prefix

src/test/InjectionTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ import com.intellij.util.containers.ContainerUtil
88
import org.junit.Assert
99

1010
class InjectionTest : LightCodeInsightFixtureTestCase() {
11+
12+
fun testTemplateArgumentIsWholeRange() {
13+
doTest("let css = css`\${someVariable}`")
14+
doTest("let globalCss = injectGlobal`\${someVariable}`")
15+
}
16+
1117
fun testCss() {
1218
doTest("let css = css`\n" +
1319
" color:red;\n" +

0 commit comments

Comments
 (0)