@@ -24,6 +24,7 @@ import com.intellij.openapi.application.ApplicationManager
2424import com.intellij.openapi.diagnostic.logger
2525import com.intellij.openapi.editor.DefaultLanguageHighlighterColors.INLINE_PARAMETER_HINT
2626import com.intellij.openapi.editor.Editor
27+ import com.intellij.openapi.editor.Inlay
2728import com.intellij.openapi.editor.colors.EditorFontType
2829import com.intellij.openapi.editor.impl.EditorImpl
2930import com.intellij.openapi.editor.markup.EffectType
@@ -36,6 +37,7 @@ import com.intellij.ui.paint.EffectPainter
3637import org.joor.Reflect
3738import spp.jetbrains.marker.SourceMarker
3839import spp.jetbrains.marker.service.ArtifactMarkService
40+ import spp.jetbrains.marker.source.mark.api.SourceMark
3941import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventCode.MARK_REMOVED
4042import spp.jetbrains.marker.source.mark.api.event.SourceMarkEventListener
4143import spp.jetbrains.marker.source.mark.api.key.SourceKey
@@ -100,20 +102,7 @@ class SourceInlayHintProvider : InlayHintsProvider<NoSettings> {
100102 FileEditorManager .getInstance(event.sourceMark.project).selectedTextEditor?.inlayModel
101103 // todo: smaller range
102104 ?.getBlockElementsInRange(0 , Integer .MAX_VALUE )?.forEach {
103- if (it.renderer is BlockInlayRenderer ) {
104- val cachedPresentation = Reflect .on(it.renderer).field(" cachedPresentation" ).get<Any >()
105- if (cachedPresentation is RecursivelyUpdatingRootPresentation ) {
106- if (cachedPresentation.content is StaticDelegatePresentation ) {
107- val delegatePresentation = cachedPresentation.content as StaticDelegatePresentation
108- if (delegatePresentation.presentation is DynamicTextInlayPresentation ) {
109- val dynamicPresentation = delegatePresentation.presentation as DynamicTextInlayPresentation
110- if (dynamicPresentation.inlayMark == event.sourceMark) {
111- Disposer .dispose(it)
112- }
113- }
114- }
115- }
116- }
105+ disposeInlayIfNecessary(it, event.sourceMark)
117106 }
118107
119108 InlayHintsPassFactory .forceHintsUpdateOnNextPass()
@@ -122,6 +111,23 @@ class SourceInlayHintProvider : InlayHintsProvider<NoSettings> {
122111 }
123112 }
124113
114+ private fun disposeInlayIfNecessary (it : Inlay <* >, sourceMark : SourceMark ) {
115+ if (it.renderer is BlockInlayRenderer ) {
116+ val cachedPresentation = Reflect .on(it.renderer).field(" cachedPresentation" ).get<Any >()
117+ if (cachedPresentation is RecursivelyUpdatingRootPresentation ) {
118+ if (cachedPresentation.content is StaticDelegatePresentation ) {
119+ val delegatePresentation = cachedPresentation.content as StaticDelegatePresentation
120+ if (delegatePresentation.presentation is DynamicTextInlayPresentation ) {
121+ val dynamicPresentation = delegatePresentation.presentation as DynamicTextInlayPresentation
122+ if (dynamicPresentation.inlayMark == sourceMark) {
123+ Disposer .dispose(it)
124+ }
125+ }
126+ }
127+ }
128+ }
129+ }
130+
125131 @Volatile
126132 @JvmField
127133 var latestInlayMarkAddedAt: Long = - 1L
0 commit comments