Skip to content

Commit d1aa33c

Browse files
authored
Fix: Support finding the MCP module of files which are currently being edited. (#2559)
`PsiFile#getVirtualFile` seems to be null in these cases, but `FileViewProvider#getVirtualFile` works correctly.
1 parent 9e21a2f commit d1aa33c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/kotlin/util/psi-utils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ fun LookupElementBuilder.withImportInsertion(toImport: List<PsiClass>): LookupEl
347347
}
348348

349349
fun PsiElement.findMcpModule() = this.cached {
350-
val file = containingFile?.virtualFile ?: return@cached null
350+
val file = containingFile?.viewProvider?.virtualFile ?: return@cached null
351351
val index = ProjectFileIndex.getInstance(project)
352352
val modules = if (index.isInLibrary(file)) {
353353
val library = index.getOrderEntriesForFile(file)

0 commit comments

Comments
 (0)