Skip to content

Commit

Permalink
remove cache on disable/uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoniRokitnicki committed Jun 12, 2024
1 parent f2379a2 commit 1b98a2c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 2 additions & 0 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
<className>com.intellij.advancedExpressionFolding.extension.methodcall.dynamic.AddDynamicMethodFoldingIntention</className>
</intentionAction>

<postStartupActivity implementation="com.intellij.advancedExpressionFolding.FoldingStartupActivity" />
</extensions>

<actions>
<action id="advanced.folding.toggle.global" class="com.intellij.advancedExpressionFolding.GlobalToggleFoldingAction"
text="Advanced Folding: Global" description="Toggle advanced folding globally across all files">
Expand Down
3 changes: 0 additions & 3 deletions src/com/intellij/advancedExpressionFolding/FoldingService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@ class FoldingService {
}

fun clearAllKeys(project: Project) {

FileEditorManager.getInstance(project).allEditors.mapNotNull {
(it as? TextEditor)?.editor
}.forEach {
clearAllKeys(it)
}

}


fun clearAllKeys(editor: Editor) {
val project = editor.project ?: return
val psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.document) ?: return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.intellij.advancedExpressionFolding

import com.intellij.advancedExpressionFolding.extension.off
import com.intellij.ide.plugins.DisabledPluginsState
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.StartupActivity

class FoldingStartupActivity : StartupActivity.Background {

private var runOnce = false

override fun runActivity(project: Project) {
runOnce.off()?.run {
@Suppress("UnstableApiUsage")
DisabledPluginsState.addDisablePluginListener {
DisabledPluginsState.getDisabledIds().firstOrNull {
it.idString == "com.github.advanced-java-folding2"
}?.run {
FoldingService.get().clearAllKeys(project)
}
}
runOnce = true
}
}
}

0 comments on commit 1b98a2c

Please sign in to comment.