InlayHints: change presentation before emit event

GitOrigin-RevId: 2503e52e854d12f966468e2f450b0a401faf887f
This commit is contained in:
Roman.Ivanov
2019-06-10 08:08:16 +03:00
committed by intellij-monorepo-bot
parent 012edcdbd7
commit 596e36dfa7
2 changed files with 15 additions and 4 deletions
@@ -117,10 +117,10 @@ class InlayHintsSinkImpl<T>(val key: SettingsKey<T>) : InlayHintsSink {
val previousPresentation = renderer.presentation
@Suppress("UNCHECKED_CAST")
newPresentation.addListener(InlayListener(inlay as Inlay<PresentationRenderer>))
renderer.presentation = newPresentation
if (newPresentation.updateState(previousPresentation)) {
newPresentation.fireUpdateEvent(previousPresentation.dimension())
}
renderer.presentation = newPresentation
hints.remove(offset)
}
}
@@ -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)