From 016f729df42c2f2544dd259bd5eaab5922cd49d3 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Tue, 1 Jul 2025 18:35:49 +0200 Subject: [PATCH] [ByteCodeViewer] IDEA-375222 Respect app-wide setting "Show directory for non-unique file names" GitOrigin-RevId: 335b0c5ef30ef2e7795ab43fac4411e2825b04c0 --- .../byteCodeViewer/BytecodeToolWindowService.kt | 10 ++++++++-- .../com/intellij/byteCodeViewer/ShowBytecodeAction.kt | 5 +---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/BytecodeToolWindowService.kt b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/BytecodeToolWindowService.kt index 4c418e6f89b0..e4275785df75 100644 --- a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/BytecodeToolWindowService.kt +++ b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/BytecodeToolWindowService.kt @@ -1,6 +1,7 @@ // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.byteCodeViewer +import com.intellij.ide.ui.UISettings import com.intellij.openapi.components.Service import com.intellij.openapi.project.Project import com.intellij.openapi.util.Disposer @@ -35,17 +36,22 @@ class BytecodeToolWindowService(private val project: Project) { val listener = object : ContentManagerListener { override fun contentAdded(event: ContentManagerEvent) { - deduplicateTabNames(toolWindow) + if (UISettings.getInstance().showDirectoryForNonUniqueFilenames) { + deduplicateTabNames(toolWindow) + } } override fun contentRemoved(event: ContentManagerEvent) { - deduplicateTabNames(toolWindow) + if (UISettings.getInstance().showDirectoryForNonUniqueFilenames) { + deduplicateTabNames(toolWindow) + } } } contentManager.addContentManagerListener(listener) registeredListeners[toolWindow] = listener Disposer.register(toolWindow.disposable) { + // The bytecode tool window cannot be "closed" contentManager.removeContentManagerListener(listener) registeredListeners.remove(toolWindow) } diff --git a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ShowBytecodeAction.kt b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ShowBytecodeAction.kt index dc80b1ef4328..fdfb2a9ecfe3 100644 --- a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ShowBytecodeAction.kt +++ b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ShowBytecodeAction.kt @@ -31,9 +31,7 @@ internal class ShowBytecodeAction : AnAction() { hideOnEmptyContent = true canCloseContent = true } - val service = BytecodeToolWindowService.getInstance(project) - - service.ensureContentManagerListenerRegistered(toolWindow) + BytecodeToolWindowService.getInstance(project).ensureContentManagerListenerRegistered(toolWindow) val editor = event.getData(CommonDataKeys.EDITOR) ?: return val psiFile = event.getData(CommonDataKeys.PSI_FILE) ?: return @@ -77,7 +75,6 @@ internal class ShowBytecodeAction : AnAction() { toolWindow.contentManager.addContent(content) - service.deduplicateTabNames(toolWindow) content.setDisposer(panel) toolWindow.contentManager.setSelectedContent(content) toolWindow.setAdditionalGearActions(createActionGroup())