1
0

Support disabling or uninstalling the plugin without an IDE restart

This commit is contained in:
chylex 2022-07-20 22:52:39 +02:00
parent 43857c2f7f
commit b9a8bdaeba
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548
3 changed files with 15 additions and 2 deletions
src/main
java/com/chylex/intellij/keeppopupswhiledebugging
resources/META-INF

View File

@ -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.")
}
}

View File

@ -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

View File

@ -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>