diff --git a/src/main/java/com/chylex/intellij/keeppopupswhiledebugging/PluginLoadListener.kt b/src/main/java/com/chylex/intellij/keeppopupswhiledebugging/PluginLoadListener.kt index f7bfee9..0262b8f 100644 --- a/src/main/java/com/chylex/intellij/keeppopupswhiledebugging/PluginLoadListener.kt +++ b/src/main/java/com/chylex/intellij/keeppopupswhiledebugging/PluginLoadListener.kt @@ -17,7 +17,7 @@ class PluginLoadListener : DynamicPluginListener { } override fun beforePluginUnload(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) { - if (pluginDescriptor.pluginId.idString == PLUGIN_ID) { + if (pluginDescriptor.pluginId.idString == PLUGIN_ID && !PreventHidingPopups.tryUninstallListener()) { throw CannotUnloadPluginException("A restart is required to unload Keep Editor Tooltips While Debugging plugin.") } } diff --git a/src/main/java/com/chylex/intellij/keeppopupswhiledebugging/PreventHidingPopups.kt b/src/main/java/com/chylex/intellij/keeppopupswhiledebugging/PreventHidingPopups.kt index ce6f401..52ff89d 100644 --- a/src/main/java/com/chylex/intellij/keeppopupswhiledebugging/PreventHidingPopups.kt +++ b/src/main/java/com/chylex/intellij/keeppopupswhiledebugging/PreventHidingPopups.kt @@ -18,6 +18,19 @@ class PreventHidingPopups : StartupActivity { EditorMouseHoverPopupControl.getInstance()?.addListener(MouseTrackingDisabledListener) } + fun tryUninstallListener(): Boolean { + val instance = EditorMouseHoverPopupControl.getInstance() ?: return true + + return try { + val listenersField = instance.javaClass.getDeclaredField("listeners").also { it.isAccessible = true } + val listeners = listenersField.get(instance) as MutableCollection<*> + listeners.remove(MouseTrackingDisabledListener) + true + } catch (e: Exception) { + false + } + } + fun enablePopupsInAllProjects() { val projectManager = ProjectManager.getInstanceIfCreated() ?: return diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index ef091d9..de2efbd 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -10,7 +10,7 @@ If you hover an element that has tooltips from both the editor and the debugger, both tooltips are shown and moving the cursor on top of one hides the other. <br><br> Installing the plugin automatically re-enables all editor tooltips, even if installed in the middle of a debugging session. - Disabling or uninstalling the plugin requires an IDE restart. + Disabling or uninstalling the plugin takes effect when the next debugging session starts. <br><br> <a href="https://youtrack.jetbrains.com/issue/IDEA-120435">IDEA-120435</a> ]]></description>