|
1 | 1 | package com.github.lppedd.cc.editor |
2 | 2 |
|
3 | 3 | import com.intellij.ide.plugins.PluginManager |
4 | | -import com.intellij.openapi.actionSystem.ActionManager |
5 | 4 | import com.intellij.openapi.actionSystem.Constraints |
6 | 5 | import com.intellij.openapi.actionSystem.DefaultActionGroup |
| 6 | +import com.intellij.openapi.actionSystem.ex.ActionRuntimeRegistrar |
7 | 7 | import com.intellij.openapi.actionSystem.impl.ActionConfigurationCustomizer |
| 8 | +import com.intellij.openapi.actionSystem.impl.ActionConfigurationCustomizer.LightCustomizeStrategy |
8 | 9 | import com.intellij.openapi.extensions.PluginId |
9 | 10 |
|
10 | 11 | /** |
11 | 12 | * @author Edoardo Luppi |
12 | 13 | */ |
13 | 14 | @Suppress("UnstableApiUsage") |
14 | | -internal class CommitTabActionConfigurationCustomizer : ActionConfigurationCustomizer { |
| 15 | +internal class CommitTabActionConfigurationCustomizer : ActionConfigurationCustomizer, LightCustomizeStrategy { |
15 | 16 | private val actionId = "EditorTab" |
16 | 17 | private val groupId = "EditorActions" |
17 | 18 |
|
18 | | - @Deprecated("Implement one of [CustomizeStrategy]") |
19 | | - override fun customize(actionManager: ActionManager) { |
| 19 | + override suspend fun customize(actionRegistrar: ActionRuntimeRegistrar) { |
20 | 20 | // Rider register its own EditorTab action, see com.jetbrains.rider.editorActions.FrontendTabAction. |
21 | 21 | // Unfortunately, that action is coded in Kotlin and marked as final, |
22 | 22 | // so the only way to avoid breaking Rider is simply to not offer |
23 | 23 | // enhanced tabbing in the commit dialog |
24 | | - if (!PluginManager.isPluginInstalled(PluginId.getId("com.intellij.modules.rider"))) { |
25 | | - val oldAction = actionManager.getActionOrStub(actionId) |
| 24 | + if (PluginManager.isPluginInstalled(PluginId.getId("com.intellij.modules.rider"))) { |
| 25 | + return |
| 26 | + } |
26 | 27 |
|
27 | | - if (oldAction != null) { |
28 | | - val actionGroup = actionManager.getAction(groupId) as DefaultActionGroup |
29 | | - val newAction = CommitTabAction() |
30 | | - actionManager.unregisterAction(actionId) |
31 | | - actionManager.registerAction(actionId, newAction) |
| 28 | + val oldAction = actionRegistrar.getActionOrStub(actionId) |
32 | 29 |
|
33 | | - // The input ActionManager must be passed in to avoid infinite recursion |
34 | | - actionGroup.addAction(newAction, Constraints.LAST, actionManager) |
35 | | - } |
| 30 | + if (oldAction != null) { |
| 31 | + val actionGroup = actionRegistrar.getActionOrStub(groupId) as DefaultActionGroup |
| 32 | + val newAction = CommitTabAction() |
| 33 | + actionRegistrar.unregisterAction(actionId) |
| 34 | + actionRegistrar.registerAction(actionId, newAction) |
| 35 | + actionRegistrar.addToGroup(actionGroup, newAction, Constraints.LAST) |
36 | 36 | } |
37 | 37 | } |
38 | 38 | } |
0 commit comments