diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/DocPreviewUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/DocPreviewUtil.java index 70c485b6b1cf..63d95d730fca 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/DocPreviewUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/DocPreviewUtil.java @@ -191,6 +191,10 @@ public class DocPreviewUtil { // We don't want to perform the replacement then. continue; } + if (end - i > 1 && i > 0 && !ALLOWED_LINK_SEPARATORS.contains(text.charAt(i - 1))) { + // Similar situation but targets head match: from = 'TextRange', text = 'getTextRange()'. + continue; + } text.replace(i, end, replaceTo); int diff = replaceTo.length() - replaceFrom.length(); for (int j = 0; j < readOnlyChanges.size(); j++) { diff --git a/platform/lang-impl/testSources/com/intellij/codeInsight/navigation/DocPreviewUtilTest.groovy b/platform/lang-impl/testSources/com/intellij/codeInsight/navigation/DocPreviewUtilTest.groovy index 31b235dcd1ca..22df21db934c 100644 --- a/platform/lang-impl/testSources/com/intellij/codeInsight/navigation/DocPreviewUtilTest.groovy +++ b/platform/lang-impl/testSources/com/intellij/codeInsight/navigation/DocPreviewUtilTest.groovy @@ -147,7 +147,7 @@ Qname''' } @Test - void substrings() { + void tailSubstrings() { def header = '''\ PsiResolveHelperImpl public static com.intellij.openapi.util.Pair<com.intellij.psi.PsiType, com.intellij.psi.ConstraintType> getSubstitutionForTypeParameterConstraint (com.intellij.psi.PsiTypeParameter typeParam, com.intellij.psi.PsiType param, com.intellij.psi.PsiType arg, boolean isContraVariantPosition, com.intellij.pom.java.LanguageLevel languageLevel)''' @@ -164,4 +164,22 @@ public static com.intellij.openapi.util.Pair<com.intellij.psi.PsiType, com.in assertEquals(expected, DocPreviewUtil.buildPreview(header, null, fullText)) } + + @Test + void headSubstrings() { + def header = '''\ +ASTNode +com.intellij.openapi.util.TextRange getTextRange ()''' + + def fullText = '''\ +
com.intellij.lang.ASTNodeTextRange getTextRange()
+ Returns the text range (a combination of starting offset in the document and length) for this node.
+
+