ModCommand (@NotNull PsiElement target) { PsiFile psiFile = target.getContainingFile(); TextRange range = target.getTextRange(); Document document = psiFile.getViewProvider().getDocument(); if (document instanceof DocumentWindow window) { range = window.injectedToHost(range); psiFile = InjectedLanguageManager.getInstance(psiFile.getProject()).getTopLevelFile(psiFile); } VirtualFile file = psiFile.getVirtualFile(); return new ModNavigate(file, range.getStartOffset(), range.getEndOffset(), range.getStartOffset()); }