From a08972374a49ccf1550bc02e631cb51af63a5849 Mon Sep 17 00:00:00 2001 From: Konstantin Hudyakov Date: Thu, 22 Jan 2026 16:53:26 +0200 Subject: [PATCH] [toolwindow] IJPL-231387 Make tabs reorder using DnD available in VCS tool windows only with a registry key Space-RevId: c71241edc57a6aa72a7f74b4fc185938520794c1 GitOrigin-RevId: 3d07f25b56eea53e08add1e1339bd22032f04fe8 --- .../toolWindow/ToolWindowInnerDragHelper.kt | 24 ++++++++++++++----- .../util/resources/misc/registry.properties | 2 ++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/toolWindow/ToolWindowInnerDragHelper.kt b/platform/platform-impl/src/com/intellij/toolWindow/ToolWindowInnerDragHelper.kt index e60da9006f0e..923db5f2cced 100644 --- a/platform/platform-impl/src/com/intellij/toolWindow/ToolWindowInnerDragHelper.kt +++ b/platform/platform-impl/src/com/intellij/toolWindow/ToolWindowInnerDragHelper.kt @@ -59,7 +59,7 @@ internal class ToolWindowInnerDragHelper(parent: Disposable, val pane: JComponen val decorator = InternalDecoratorImpl.findTopLevelDecorator(child) val editorSupport = getEditorSupport(decorator) if (decorator != null && - (canReorderTabs() || decorator.toolWindow.canSplitTabs()) && + (canReorderTabs(decorator) || decorator.toolWindow.canSplitTabs()) && child is ContentTabLabel && (child.parent is ToolWindowContentUi.TabPanel || Registry.`is`("debugger.new.tool.window.layout.dnd", false) && child.parent is SingleContentLayout.TabAdapter) && @@ -79,7 +79,7 @@ internal class ToolWindowInnerDragHelper(parent: Disposable, val pane: JComponen return when (curLocation) { is DropLocation.ToolWindow -> { val component = curLocation.decorator - val canDrop = currentDropIndex != -1 && canReorderTabs() || curLocation.decorator.toolWindow.canSplitTabs() + val canDrop = currentDropIndex != -1 && canReorderTabs(component) || curLocation.decorator.toolWindow.canSplitTabs() component.contains(point.getPoint(component)) && canDrop } is DropLocation.Editor -> { @@ -393,7 +393,7 @@ internal class ToolWindowInnerDragHelper(parent: Disposable, val pane: JComponen val content = myDraggingTab?.content curDropLocation = when { - decorator != null && decorator == sourceDecorator && canReorderTabs() -> { + decorator != null && decorator == sourceDecorator && canReorderTabs(decorator) -> { // Drop into the same tool window decorator - always allowed. DropLocation.ToolWindow(decorator) } @@ -426,7 +426,7 @@ internal class ToolWindowInnerDragHelper(parent: Disposable, val pane: JComponen private fun highlightToolWindowDropArea(decorator: InternalDecoratorImpl, point: RelativePoint) { currentDropIndex = getTabIndex(point) - if (currentDropIndex != -1 && (canReorderTabs() || decorator.toolWindow.canSplitTabs())) { + if (currentDropIndex != -1 && (canReorderTabs(decorator) || decorator.toolWindow.canSplitTabs())) { decorator.setDropInfoIndex(currentDropIndex, dragImageView!!.size.width) currentDropSide = -1 highlighter.bounds = Rectangle() @@ -470,8 +470,11 @@ internal class ToolWindowInnerDragHelper(parent: Disposable, val pane: JComponen else null } - private fun canReorderTabs(): Boolean { - return AppModeAssertions.isMonolith() && Registry.`is`("ide.allow.tool.window.tabs.reorder", false) + private fun canReorderTabs(decorator: InternalDecoratorImpl): Boolean { + return AppModeAssertions.isMonolith() + && Registry.`is`("ide.allow.tool.window.tabs.reorder", false) + && (Registry.`is`("ide.allow.tool.window.tabs.reorder.vcs", true) + || decorator.toolWindow.id !in VCS_TOOLWINDOW_IDS) } private sealed interface DropLocation { @@ -502,4 +505,13 @@ internal class ToolWindowInnerDragHelper(parent: Disposable, val pane: JComponen pack() } } + + companion object { + private val VCS_TOOLWINDOW_IDS = listOf( + "Commit", + "Version Control", + "Pull Requests", + "Merge Requests", + ) + } } \ No newline at end of file diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 760f4bc8f52c..0781917132ce 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -142,6 +142,8 @@ ide.switcher.tool.window.list=true ide.switcher.tool.window.list.description=Shows a list of tool windows in the Switcher popup ide.allow.tool.window.tabs.reorder=true ide.allow.tool.window.tabs.reorder.description=Whether reordering tool window tabs using drag and drop is allowed +ide.allow.tool.window.tabs.reorder.vcs=false +ide.allow.tool.window.tabs.reorder.vcs.description=Whether reordering tool window tabs using drag and drop is allowed in VCS tool windows ide.tool.window.prevent.move.resize.timeout=100 ide.tool.window.prevent.move.resize.timeout.description=Time interval (in ms) after showing a detached (floating or windowed) tool window during which\ OS/JBR-induced moves and resizes will be prevented. Set to a negative value to disable this functionality