mirror of
https://github.com/chylex/IntelliJ-AceJump.git
synced 2024-11-25 17:42:46 +01:00
Compare commits
4 Commits
100001ffca
...
e005983d4c
Author | SHA1 | Date | |
---|---|---|---|
e005983d4c | |||
8f4d9748ad | |||
76c6458ef4 | |||
2f53e9da6d |
@ -8,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "org.acejump"
|
||||
version = "chylex-13"
|
||||
version = "chylex-14"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -21,7 +21,7 @@ kotlin {
|
||||
intellij {
|
||||
version.set("2023.2")
|
||||
updateSinceUntilBuild.set(false)
|
||||
plugins.add("IdeaVIM:chylex-16")
|
||||
plugins.add("IdeaVIM:chylex-20")
|
||||
|
||||
pluginsRepositories {
|
||||
custom("https://intellij.chylex.com")
|
||||
|
@ -1,5 +1,8 @@
|
||||
package org.acejump.action
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionManager
|
||||
import com.intellij.openapi.actionSystem.IdeActions
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.command.CommandProcessor
|
||||
import com.intellij.openapi.command.UndoConfirmationPolicy
|
||||
import com.intellij.openapi.editor.Document
|
||||
@ -9,6 +12,7 @@ import com.intellij.openapi.fileEditor.TextEditor
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
|
||||
import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.playback.commands.ActionCommand
|
||||
import org.acejump.search.SearchProcessor
|
||||
|
||||
/**
|
||||
@ -49,6 +53,14 @@ sealed class AceTagAction {
|
||||
caretModel.moveToOffset(offset)
|
||||
}
|
||||
|
||||
fun performAction(actionName: String) {
|
||||
val actionManager = ActionManager.getInstance()
|
||||
val action = actionManager.getAction(actionName)
|
||||
if (action != null) {
|
||||
actionManager.tryToExecute(action, ActionCommand.getInputEvent(null), null, null, true)
|
||||
}
|
||||
}
|
||||
|
||||
fun ensureEditorFocused(editor: Editor) {
|
||||
val project = editor.project ?: return
|
||||
val fem = FileEditorManagerEx.getInstanceEx(project)
|
||||
@ -81,4 +93,16 @@ sealed class AceTagAction {
|
||||
return offset
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On default action, performs the Go To Declaration action, available via `Navigate | Declaration or Usages`.
|
||||
* On shift action, performs the Go To Type Declaration action, available via `Navigate | Type Declaration`.
|
||||
* Always places the caret at the start of the word.
|
||||
*/
|
||||
object GoToDeclaration : AceTagAction() {
|
||||
override fun invoke(editor: Editor, searchProcessor: SearchProcessor, offset: Int, shiftMode: Boolean, isFinal: Boolean) {
|
||||
JumpToSearchStart(editor, searchProcessor, offset, shiftMode = false, isFinal = isFinal)
|
||||
ApplicationManager.getApplication().invokeLater { performAction(if (shiftMode) IdeActions.ACTION_GOTO_TYPE_DECLARATION else IdeActions.ACTION_GOTO_DECLARATION) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,10 @@ import com.maddyhome.idea.vim.helper.vimSelectionStart
|
||||
import com.maddyhome.idea.vim.helper.vimStateMachine
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import com.maddyhome.idea.vim.state.mode.SelectionType
|
||||
import org.acejump.boundaries.StandardBoundaries.*
|
||||
import org.acejump.boundaries.StandardBoundaries.AFTER_CARET
|
||||
import org.acejump.boundaries.StandardBoundaries.BEFORE_CARET
|
||||
import org.acejump.boundaries.StandardBoundaries.CARET_LINE
|
||||
import org.acejump.boundaries.StandardBoundaries.VISIBLE_ON_SCREEN
|
||||
import org.acejump.modes.JumpMode
|
||||
import org.acejump.search.Pattern
|
||||
import org.acejump.search.Tag
|
||||
@ -83,6 +86,7 @@ sealed class AceVimAction : DumbAwareAction() {
|
||||
}
|
||||
}
|
||||
|
||||
injector.scroll.scrollCaretIntoView(editor.vim)
|
||||
mode.finishSession(editor, session)
|
||||
return true
|
||||
}
|
||||
@ -159,4 +163,25 @@ sealed class AceVimAction : DumbAwareAction() {
|
||||
class JumpUWordEndBackward : AceVimAction() {
|
||||
override val mode = AceVimMode.JumpToPattern(Pattern.VIM_UWORD_END, BEFORE_CARET.intersection(VISIBLE_ON_SCREEN))
|
||||
}
|
||||
|
||||
class JumpAllEditorsGoToDeclaration : DumbAwareAction() {
|
||||
override fun update(action: AnActionEvent) {
|
||||
action.presentation.isEnabled = action.getData(CommonDataKeys.EDITOR) != null
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val editor = e.getData(CommonDataKeys.EDITOR) ?: return
|
||||
val session = SessionManager.start(editor, AceVimMode.JumpAllEditors.getJumpEditors(editor))
|
||||
|
||||
session.defaultBoundary = VISIBLE_ON_SCREEN
|
||||
session.startJumpMode {
|
||||
object : JumpMode() {
|
||||
override fun accept(state: SessionState, acceptedTag: Tag): Boolean {
|
||||
state.act(AceTagAction.GoToDeclaration, acceptedTag, shiftMode = wasUpperCase, isFinal = true)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
<actions>
|
||||
<action id="AceVimAction_JumpAllEditors" class="org.acejump.action.AceVimAction$JumpAllEditors" text="AceJump Vim - Jump All Editors" />
|
||||
<action id="AceVimAction_JumpAllEditors_GoToDeclaration" class="org.acejump.action.AceVimAction$JumpAllEditorsGoToDeclaration" text="AceJump Vim - Jump All Editors - Go To Declaration" />
|
||||
<action id="AceVimAction_JumpForward" class="org.acejump.action.AceVimAction$JumpForward" text="AceJump Vim - Jump Forward" />
|
||||
<action id="AceVimAction_JumpBackward" class="org.acejump.action.AceVimAction$JumpBackward" text="AceJump Vim - Jump Backward" />
|
||||
<action id="AceVimAction_JumpTillForward" class="org.acejump.action.AceVimAction$JumpTillForward" text="AceJump Vim - Jump Till Forward" />
|
||||
|
Loading…
Reference in New Issue
Block a user