Skip to content

Commit 6e548ef

Browse files
committed
Modify match read to fix Index exception in case of base package import
1 parent c124f7f commit 6e548ef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/kotlin/org/javacs/kt/completion/completions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private fun doCompletions(file: CompiledFile, cursor: Int, surroundingElement: K
112112
LOG.info("Completing import '${surroundingElement.text}'")
113113
val module = file.container.get<ModuleDescriptor>()
114114
val match = Regex("import ((\\w+\\.)*)[\\w*]*").matchEntire(surroundingElement.text) ?: return doesntLookLikeImport(surroundingElement)
115-
val parentDot = match.groups[1]?.value ?: "."
115+
val parentDot = if (match.groupValues[1].isNotBlank()) match.groupValues[1] else "."
116116
val parent = parentDot.substring(0, parentDot.length - 1)
117117
LOG.fine("Looking for members of package '$parent'")
118118
val parentPackage = module.getPackage(FqName.fromSegments(parent.split('.')))
@@ -407,4 +407,4 @@ private fun empty(message: String): CompletionList {
407407
LOG.fine(message)
408408

409409
return CompletionList(true, emptyList())
410-
}
410+
}

0 commit comments

Comments
 (0)