From 7a2794ae3e69e6834c8614ff0342d800e4e1d094 Mon Sep 17 00:00:00 2001 From: Dmitry Zhuravlev Date: Wed, 7 Jan 2026 19:21:14 +0100 Subject: [PATCH] [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 --- .../diff/tools/combined/CombinedDiffViewer.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/platform/diff-impl/src/com/intellij/diff/tools/combined/CombinedDiffViewer.kt b/platform/diff-impl/src/com/intellij/diff/tools/combined/CombinedDiffViewer.kt index 0bc44069c26d..da7bf91a9a46 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/combined/CombinedDiffViewer.kt +++ b/platform/diff-impl/src/com/intellij/diff/tools/combined/CombinedDiffViewer.kt @@ -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, ) { 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)