Skip to content

Commit

Permalink
Improve the presentation of GraphQL elements when navigating to them
Browse files Browse the repository at this point in the history
  • Loading branch information
BoD committed May 16, 2024
1 parent 457f0c4 commit 8433b87
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.intellij.navigation.NavigationItem
import com.intellij.platform.backend.navigation.NavigationRequest
import com.intellij.pom.Navigatable
import com.intellij.psi.PsiElement
import javax.swing.Icon

private class LogNavigationPsiElement(
private val wrapped: PsiElement,
Expand All @@ -24,8 +25,13 @@ private class LogNavigationPsiElement(
return (wrapped as? NavigationItem)?.name
}

override fun getPresentation(): ItemPresentation? {
return (wrapped as? NavigationItem)?.presentation
override fun getPresentation(): ItemPresentation {
return (wrapped as? NavigationItem)?.presentation ?: object : ItemPresentation {
// We don't want the presentation to be too wide: fallback to the first line of text, truncated to 80 characters
override fun getPresentableText(): String? = wrapped.text.split('\n').firstOrNull()?.take(80)

override fun getIcon(unused: Boolean): Icon? = null
}
}

@Suppress("UnstableApiUsage")
Expand Down

0 comments on commit 8433b87

Please sign in to comment.