Skip to content

Commit

Permalink
Stop IdeaVim actions flowing into JB Client
Browse files Browse the repository at this point in the history
IdeaVim actions are local only - they control local behaviour and should not be visible in the Client

Fixes VIM-3283
  • Loading branch information
citizenmatt authored and AlexPl292 committed Feb 23, 2024
1 parent 66ff56a commit bd19256
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package com.maddyhome.idea.vim.action
import com.intellij.openapi.actionSystem.ActionPlaces
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.remoting.ActionRemoteBehaviorSpecification
import com.intellij.openapi.project.DumbAwareToggleAction
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.helper.MessageHelper
Expand All @@ -19,7 +20,7 @@ import com.maddyhome.idea.vim.helper.MessageHelper
* This class is used to handle the Vim Plugin enabled/disabled toggle. This is most likely used as a menu option
* but could also be used as a toolbar item.
*/
internal class VimPluginToggleAction : DumbAwareToggleAction()/*, LightEditCompatible*/ {
internal class VimPluginToggleAction : DumbAwareToggleAction(), ActionRemoteBehaviorSpecification.Disabled/*, LightEditCompatible*/ {
override fun isSelected(event: AnActionEvent): Boolean = VimPlugin.isEnabled()

override fun setSelected(event: AnActionEvent, b: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.AnActionWrapper
import com.intellij.openapi.actionSystem.PlatformDataKeys
import com.intellij.openapi.actionSystem.remoting.ActionRemoteBehaviorSpecification
import com.intellij.openapi.application.invokeLater
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.editor.Editor
Expand Down Expand Up @@ -59,7 +60,7 @@ import javax.swing.KeyStroke
* This class is used in Which-Key plugin, so don't make it internal. Generally, we should provide a proper
* way to get ideavim keys for this plugin. See VIM-3085
*/
public class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatible*/ {
public class VimShortcutKeyAction : AnAction(), DumbAware, ActionRemoteBehaviorSpecification.Disabled/*, LightEditCompatible*/ {
private val traceTime: Boolean
get() {
// Make sure the injector is initialized
Expand Down Expand Up @@ -390,4 +391,4 @@ private class ActionEnableStatus(

private enum class LogLevel {
DEBUG, INFO, ERROR,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.actionSystem.remoting.ActionRemoteBehaviorSpecification
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.EditorCustomElementRenderer
import com.intellij.openapi.editor.Inlay
Expand All @@ -32,7 +33,7 @@ import java.util.*
import javax.swing.UIManager
import kotlin.math.max

internal class AddBlockInlaysAction : AnAction() {
internal class AddBlockInlaysAction : AnAction(), ActionRemoteBehaviorSpecification.Disabled {
override fun actionPerformed(e: AnActionEvent) {
val dataContext = e.dataContext
val editor = getEditor(dataContext) ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.actionSystem.remoting.ActionRemoteBehaviorSpecification
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.VisualPosition
import com.maddyhome.idea.vim.api.lineLength
Expand All @@ -22,7 +23,7 @@ import com.maddyhome.idea.vim.newapi.vim
import java.util.*
import kotlin.math.max

internal class AddInlineInlaysAction : AnAction() {
internal class AddInlineInlaysAction : AnAction(), ActionRemoteBehaviorSpecification.Disabled {
companion object {
private val random = Random()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.intellij.openapi.actionSystem.AnActionWrapper
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.actionSystem.ex.AnActionListener
import com.intellij.openapi.actionSystem.impl.ProxyShortcutSet
import com.intellij.openapi.actionSystem.remoting.ActionRemoteBehaviorSpecification
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.DumbAwareToggleAction
import com.intellij.openapi.util.TextRange
Expand Down Expand Up @@ -207,7 +208,7 @@ internal object IdeaSpecifics {
}

//region Find action ID
internal class FindActionIdAction : DumbAwareToggleAction() {
internal class FindActionIdAction : DumbAwareToggleAction(), ActionRemoteBehaviorSpecification.Disabled {
override fun isSelected(e: AnActionEvent): Boolean = injector.globalIjOptions().trackactionids

override fun setSelected(e: AnActionEvent, state: Boolean) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/maddyhome/idea/vim/ui/ReloadVimRc.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.actionSystem.PlatformDataKeys
import com.intellij.openapi.actionSystem.remoting.ActionRemoteBehaviorSpecification
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.toolbar.floating.AbstractFloatingToolbarProvider
Expand Down Expand Up @@ -109,7 +110,7 @@ internal object VimRcFileState : VimrcFileState {
}
}

internal class ReloadVimRc : DumbAwareAction() {
internal class ReloadVimRc : DumbAwareAction(), ActionRemoteBehaviorSpecification.Disabled {
override fun update(e: AnActionEvent) {
val editor = e.getData(PlatformDataKeys.EDITOR) ?: run {
e.presentation.isEnabledAndVisible = false
Expand Down Expand Up @@ -172,7 +173,7 @@ internal class ReloadFloatingToolbar : AbstractFloatingToolbarProvider(ACTION_GR
}
}

internal class ReloadFloatingToolbarActionGroup : DefaultActionGroup() {
internal class ReloadFloatingToolbarActionGroup : DefaultActionGroup(), ActionRemoteBehaviorSpecification.Disabled {
companion object {
const val ACTION_GROUP = "IdeaVim.ReloadVimRc.group"
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/maddyhome/idea/vim/ui/StatusBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.openapi.actionSystem.DefaultActionGroup
import com.intellij.openapi.actionSystem.remoting.ActionRemoteBehaviorSpecification
import com.intellij.openapi.application.impl.LaterInvocator
import com.intellij.openapi.fileTypes.PlainTextLanguage
import com.intellij.openapi.options.ShowSettingsUtil
Expand Down Expand Up @@ -145,7 +146,7 @@ internal class VimStatusBar : StatusBarWidget, StatusBarWidget.IconPresentation
override fun getPresentation(): StatusBarWidget.WidgetPresentation = this
}

internal class VimActions : DumbAwareAction() {
internal class VimActions : DumbAwareAction(), ActionRemoteBehaviorSpecification.Disabled {

override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package com.maddyhome.idea.vim.ui.widgets.mode
import com.intellij.ide.ui.LafManager
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.remoting.ActionRemoteBehaviorSpecification
import com.intellij.openapi.ui.DialogPanel
import com.intellij.openapi.ui.popup.JBPopup
import com.intellij.openapi.ui.popup.JBPopupFactory
Expand Down Expand Up @@ -44,7 +45,7 @@ import javax.swing.JPanel
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

public class ModeWidgetPopup : AnAction() {
public class ModeWidgetPopup : AnAction(), ActionRemoteBehaviorSpecification.Disabled {
public override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
val popup = createPopup() ?: return
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@
<xi:include href="/META-INF/includes/VimExtensions.xml" xpointer="xpointer(/idea-plugin/*)"/>
<xi:include href="/META-INF/includes/VimListeners.xml" xpointer="xpointer(/idea-plugin/*)"/>

<!--
IMPORTANT!
Please make sure that all actions added implement the ActionRemoteBehaviorSpecification.Disabled interface on your
action. This will prevent the action from flowing from a Code With Me host to the JetBrains Client
-->
<actions resource-bundle="messages.IdeaVimBundle">
<action id="VimPluginToggle" class="com.maddyhome.idea.vim.action.VimPluginToggleAction">
<add-to-group group-id="ToolsMenu" anchor="last"/>
Expand Down

0 comments on commit bd19256

Please sign in to comment.