From b7b36a75925948d25f59d9eaf30ca1ee7af372d5 Mon Sep 17 00:00:00 2001 From: Nikolay Plyusnin Date: Fri, 20 Oct 2023 16:40:28 +0300 Subject: [PATCH] [RIDER] change cursor on inlays hover GitOrigin-RevId: 1339f18946074ff10d71d80d740954efb2b96385 --- .../codeInsight/hints/presentation/PresentationFactory.kt | 5 +++++ .../hints/presentation/WithCursorOnHoverPresentation.kt | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hints/presentation/PresentationFactory.kt b/platform/lang-impl/src/com/intellij/codeInsight/hints/presentation/PresentationFactory.kt index 0facd981b686..683fd65ac648 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hints/presentation/PresentationFactory.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/hints/presentation/PresentationFactory.kt @@ -309,6 +309,11 @@ class PresentationFactory(private val editor: Editor) : InlayPresentationFactory return WithCursorOnHoverPresentation(base, cursor, editor) } + @Contract(pure = true) + fun withCursorOnHoverWhenControlDown (base: InlayPresentation, cursor: Cursor): InlayPresentation { + return WithCursorOnHoverPresentation(base, cursor, editor) { isControlDown(it) } + } + @Contract(pure = true) fun withReferenceAttributes(noHighlightReference: InlayPresentation): WithAttributesPresentation { return attributes(noHighlightReference, REFERENCE_HYPERLINK_COLOR, diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hints/presentation/WithCursorOnHoverPresentation.kt b/platform/lang-impl/src/com/intellij/codeInsight/hints/presentation/WithCursorOnHoverPresentation.kt index 2f08d88be070..3dd0a0bbbfb4 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hints/presentation/WithCursorOnHoverPresentation.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/hints/presentation/WithCursorOnHoverPresentation.kt @@ -10,11 +10,12 @@ import java.awt.event.MouseEvent class WithCursorOnHoverPresentation( presentation: InlayPresentation, val cursor: Cursor, - private val editor: Editor) : StaticDelegatePresentation(presentation) { + private val editor: Editor, + private val onHoverPredicate: (MouseEvent) -> Boolean = { true }) : StaticDelegatePresentation(presentation) { override fun mouseMoved(event: MouseEvent, translated: Point) { super.mouseMoved(event, translated) - (editor as? EditorImpl)?.setCustomCursor(this::class, cursor) + (editor as? EditorImpl)?.setCustomCursor(this::class, if (onHoverPredicate(event)) cursor else null) } override fun mouseExited() {