diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hints/InlayHintsSinkImpl.kt b/platform/lang-impl/src/com/intellij/codeInsight/hints/InlayHintsSinkImpl.kt index d40c2ec9d492..2a196dceba2b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hints/InlayHintsSinkImpl.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/hints/InlayHintsSinkImpl.kt @@ -117,10 +117,10 @@ class InlayHintsSinkImpl(val key: SettingsKey) : InlayHintsSink { val previousPresentation = renderer.presentation @Suppress("UNCHECKED_CAST") newPresentation.addListener(InlayListener(inlay as Inlay)) + renderer.presentation = newPresentation if (newPresentation.updateState(previousPresentation)) { newPresentation.fireUpdateEvent(previousPresentation.dimension()) } - renderer.presentation = newPresentation hints.remove(offset) } } diff --git a/platform/lang-impl/testSources/com/intellij/codeInsight/hints/PresentationTest.kt b/platform/lang-impl/testSources/com/intellij/codeInsight/hints/PresentationTest.kt index 566d3804c6d4..a1dc23f95674 100644 --- a/platform/lang-impl/testSources/com/intellij/codeInsight/hints/PresentationTest.kt +++ b/platform/lang-impl/testSources/com/intellij/codeInsight/hints/PresentationTest.kt @@ -126,7 +126,7 @@ class HeavyPresentationTest : LightPlatformCodeInsightFixtureTestCase() { } fun testFoldedStateIsNotUpdatedAndStatelessComponentIsUpdated() { - val factory = PresentationFactory(myFixture.editor as EditorImpl) + val factory = getFactory() val old = unwrapFolding(factory.folding(factory.smallText("outerPlaceholder")) { unwrapFolding(factory.folding(factory.smallText("innerPlaceholder")) {factory.smallText("text")}) @@ -142,8 +142,7 @@ class HeavyPresentationTest : LightPlatformCodeInsightFixtureTestCase() { } fun testFoldedBiState() { - val factory = PresentationFactory(myFixture.editor as EditorImpl) - with(factory) { + with(getFactory()) { val inner = collapsible( prefix = smallText("("), collapsed = smallText("???"), @@ -179,6 +178,18 @@ class HeavyPresentationTest : LightPlatformCodeInsightFixtureTestCase() { } } + fun testSeqSmallTextChangesWidth() { + with(getFactory()) { + val initial = roundWithBackground(seq(smallText(": "), smallText("number"))) + val final = roundWithBackground(seq(smallText(": "), smallText("void"))) + val requiresUpdate = final.updateState(initial) + assertTrue(requiresUpdate) + assertTrue(initial.width != final.width) + } + } + + private fun getFactory() = PresentationFactory(myFixture.editor as EditorImpl) + private fun unwrapFolding(presentation: InlayPresentation): InlayPresentation { presentation as ChangeOnClickPresentation presentation.state = ChangeOnClickPresentation.State(true)