diff --git a/plugins/terminal/frontend/resources/intellij.terminal.frontend.xml b/plugins/terminal/frontend/resources/intellij.terminal.frontend.xml index da1fe6b215af..2bb6e10c6d96 100644 --- a/plugins/terminal/frontend/resources/intellij.terminal.frontend.xml +++ b/plugins/terminal/frontend/resources/intellij.terminal.frontend.xml @@ -5,6 +5,8 @@ + diff --git a/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/TerminalAllowedActionsProvider.kt b/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/TerminalAllowedActionsProvider.kt new file mode 100644 index 000000000000..70d90bdc1148 --- /dev/null +++ b/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/TerminalAllowedActionsProvider.kt @@ -0,0 +1,13 @@ +package com.intellij.terminal.frontend.view + +import com.intellij.openapi.extensions.ExtensionPointName +import org.jetbrains.annotations.ApiStatus + +@ApiStatus.Experimental +interface TerminalAllowedActionsProvider { + fun getActionIds(): List + + companion object { + internal val EP_NAME = ExtensionPointName.create("org.jetbrains.plugins.terminal.allowedActionsProvider") + } +} \ No newline at end of file diff --git a/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/impl/TerminalEventDispatcher.kt b/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/impl/TerminalEventDispatcher.kt index 54e99297a2a0..ca9927c38d3c 100644 --- a/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/impl/TerminalEventDispatcher.kt +++ b/plugins/terminal/frontend/src/com/intellij/terminal/frontend/view/impl/TerminalEventDispatcher.kt @@ -19,6 +19,7 @@ import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.registry.Registry import com.intellij.terminal.JBTerminalSystemSettingsProviderBase import com.intellij.terminal.frontend.action.SendShortcutToTerminalAction +import com.intellij.terminal.frontend.view.TerminalAllowedActionsProvider import com.intellij.util.concurrency.ThreadingAssertions import com.jediterm.terminal.emulator.mouse.MouseMode import org.intellij.lang.annotations.Language @@ -98,16 +99,19 @@ private class TerminalEventDispatcher( fun registerIfNeeded() { ThreadingAssertions.assertEventDispatchThread() if (!settings.overrideIdeShortcuts()) return // handled by the listener instead - this.allowedActions = getAllowedActions() + + val actionManager = ActionManager.getInstance() + val actions = getAllowedActionIds().mapNotNull { actionManager.getAction(it) } + this.allowedActions = actions if (!myRegistered) { IdeEventQueue.getInstance().addDispatcher(this, parentDisposable) - sendShortcutAction.register(editor.contentComponent, getAllowedActions()) + sendShortcutAction.register(editor.contentComponent, actions) myRegistered = true // The same reasoning as with the initialization: // the terminal might have been activated with a shortcut that will be immediately followed by a "key typed" event. // If that's the case, we should ignore that event. If not, the flag will be cleared when the next event is processed. ignoreNextKeyTypedEvent = true - LOG.trace { "Dispatcher registered: start capturing key events" } + LOG.trace { "Dispatcher registered: start capturing key events. Allowed actions: ${actions.map { it.javaClass.name }}" } } } @@ -140,9 +144,10 @@ private class TerminalEventDispatcher( return false } - private fun getAllowedActions(): List { - val actionManager = ActionManager.getInstance() - return ALLOWED_ACTION_IDS.mapNotNull { actionId -> actionManager.getAction(actionId) } + private fun getAllowedActionIds(): List { + val actionIds = LinkedHashSet(ALLOWED_ACTION_IDS) + TerminalAllowedActionsProvider.EP_NAME.extensionList.flatMapTo(actionIds) { it.getActionIds() } + return actionIds.toList() } companion object {