1
0
mirror of https://github.com/chylex/IntelliJ-Inspection-Lens.git synced 2025-04-21 15:15:46 +02:00

Fix hover underline not disappearing when scrolling without moving the mouse

This commit is contained in:
chylex 2025-01-03 22:45:15 +01:00
parent 603b35abdb
commit 0f41b22872
Signed by: chylex
SSH Key Fingerprint: SHA256:WqM8X/1DDn11LbYM0H5wsqZUjbcKxVsic37L+ERcF4o

View File

@ -16,6 +16,7 @@ import com.intellij.ui.paint.EffectPainter
import java.awt.Cursor
import java.awt.Graphics
import java.awt.Graphics2D
import java.awt.MouseInfo
import java.awt.Point
import java.awt.Rectangle
import java.awt.event.MouseEvent
@ -54,7 +55,7 @@ class LensRenderer(private var info: HighlightInfo, settings: LensSettingsState)
fixBaselineForTextRendering(r)
super.paint(inlay, g, r, textAttributes)
if (hovered) {
if (hovered && isHoveringText()) {
paintHoverEffect(inlay, g, r)
}
}
@ -124,6 +125,16 @@ class LensRenderer(private var info: HighlightInfo, settings: LensSettingsState)
}
}
private fun isHoveringText(): Boolean {
val bounds = inlay.bounds ?: return false
val translatedPoint = MouseInfo.getPointerInfo().location.apply {
SwingUtilities.convertPointFromScreen(this, inlay.editor.contentComponent)
translate(-bounds.x, -bounds.y)
}
return isHoveringText(translatedPoint)
}
private fun isHoveringText(point: Point): Boolean {
return point.x >= HOVER_HORIZONTAL_PADDING
&& point.y >= 4