mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-04-16 02:15:43 +02:00
Add functionality to track action ids
This commit is contained in:
parent
ac4755a6ff
commit
1863cbdef0
resources/META-INF
src/com/maddyhome/idea/vim
@ -96,5 +96,9 @@
|
||||
<keyboard-shortcut first-keystroke="meta shift I" keymap="Mac OS X 10.5+" replace-all="true"/>
|
||||
</action>
|
||||
</group>
|
||||
|
||||
<action id="VimFindActionIdAction"
|
||||
class="com.maddyhome.idea.vim.listener.FindActionIdAction" text="Track Action Ids"
|
||||
description="Starts tracking ids of executed actions"/>
|
||||
</actions>
|
||||
</idea-plugin>
|
||||
|
@ -141,6 +141,10 @@ class NotificationService(private val project: Project?) {
|
||||
NotificationType.INFORMATION).notify(project)
|
||||
}
|
||||
|
||||
fun notifyActionId(id: String) {
|
||||
Notification(IDEAVIM_NOTIFICATION_ID, IDEAVIM_NOTIFICATION_TITLE, "Action id: $id", NotificationType.INFORMATION).notify(project)
|
||||
}
|
||||
|
||||
class OpenIdeaVimRcAction(private val notification: Notification?) : DumbAwareAction("Open ~/.ideavimrc") {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val eventProject = e.project
|
||||
|
@ -36,6 +36,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionManager
|
||||
import com.intellij.openapi.editor.event.CaretEvent
|
||||
import com.intellij.openapi.editor.event.CaretListener
|
||||
import com.intellij.openapi.project.DumbAwareToggleAction
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.util.PlatformUtils
|
||||
import com.maddyhome.idea.vim.EventFacade
|
||||
@ -70,7 +71,16 @@ object IdeaSpecifics {
|
||||
private var editor: Editor? = null
|
||||
override fun beforeActionPerformed(action: AnAction, dataContext: DataContext, event: AnActionEvent) {
|
||||
if (!VimPlugin.isEnabled()) return
|
||||
editor = dataContext.getData(CommonDataKeys.HOST_EDITOR) ?: return
|
||||
|
||||
val hostEditor = dataContext.getData(CommonDataKeys.HOST_EDITOR)
|
||||
if (hostEditor != null) {
|
||||
editor = hostEditor
|
||||
}
|
||||
|
||||
if (FindActionId.enabled) {
|
||||
val id = ActionManager.getInstance().getId(action) ?: "--NO_ID--"
|
||||
VimPlugin.getNotifications(dataContext.getData(CommonDataKeys.PROJECT)).notifyActionId(id)
|
||||
}
|
||||
}
|
||||
|
||||
override fun afterActionPerformed(action: AnAction, dataContext: DataContext, event: AnActionEvent) {
|
||||
@ -179,3 +189,15 @@ object IdeaSpecifics {
|
||||
}
|
||||
//endregion
|
||||
}
|
||||
|
||||
class FindActionIdAction : DumbAwareToggleAction() {
|
||||
override fun isSelected(e: AnActionEvent): Boolean = FindActionId.enabled
|
||||
|
||||
override fun setSelected(e: AnActionEvent, state: Boolean) {
|
||||
FindActionId.enabled = state
|
||||
}
|
||||
}
|
||||
|
||||
object FindActionId {
|
||||
var enabled = false
|
||||
}
|
Loading…
Reference in New Issue
Block a user