[combined-diff]: fix hiding visible in viewport blocks (IJPL-222577)

* Fix hiding visible (in viewport) blocks while scrolling
* Keep priority-based order, from highest to lowest (scroll from top to bottom): blocks around current, in viewport, after viewport, before viewport

Follow-up: aefc25bd6cf752b8b564487a0d8dbeead63a9350

GitOrigin-RevId: 6ec25842f73347394266dcbf7bfc163c4f451c4a
This commit is contained in:
Dmitry Zhuravlev
2026-01-07 22:46:55 +00:00
committed by intellij-monorepo-bot
parent da03ff655c
commit 7a2794ae3e
@@ -1,4 +1,4 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.diff.tools.combined
import com.intellij.diff.DiffContext
@@ -385,13 +385,11 @@ class CombinedDiffViewer(
hidden: ArrayList<CombinedBlockId>,
) {
val currentBlock = blockState.currentBlock
val totalVisible = getBlocksAroundCurrent(currentBlock)
val blocksAroundCurrent = getBlocksAroundCurrent(currentBlock)
val viewportVisible = inViewport + afterViewport + beforeViewport
val totalVisible = (blocksAroundCurrent + viewportVisible).distinct()
val blocksToHide =
hidden.filter { it !in totalVisible } +
inViewport.filter { it !in totalVisible } +
beforeViewport.filter { it !in totalVisible } +
afterViewport.filter { it !in totalVisible }
val blocksToHide = hidden.filter { it !in totalVisible }
if (blocksToHide.isNotEmpty()) {
blockListeners.multicaster.blocksHidden(blocksToHide)