1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-11-05 04:22:18 +01:00

Compare commits

...

2 Commits

Author SHA1 Message Date
dd8bfac3cf Set plugin version to chylex-26 2024-01-27 08:52:51 +01:00
fa434074d7 Apply scrolloff after executing native IDEA actions 2024-01-27 08:52:09 +01:00
2 changed files with 35 additions and 28 deletions

View File

@@ -11,7 +11,7 @@
ideaVersion=2023.3.2 ideaVersion=2023.3.2
downloadIdeaSources=true downloadIdeaSources=true
instrumentPluginCode=true instrumentPluginCode=true
version=chylex-1 version=chylex-26
javaVersion=17 javaVersion=17
remoteRobotVersion=0.11.21 remoteRobotVersion=0.11.21
antlrVersion=4.10.1 antlrVersion=4.10.1

View File

@@ -56,6 +56,7 @@ internal object IdeaSpecifics {
private val surrounderAction = private val surrounderAction =
"com.intellij.codeInsight.generation.surroundWith.SurroundWithHandler\$InvokeSurrounderAction" "com.intellij.codeInsight.generation.surroundWith.SurroundWithHandler\$InvokeSurrounderAction"
private var editor: Editor? = null private var editor: Editor? = null
private var caretOffset = -1
private var completionPrevDocumentLength: Int? = null private var completionPrevDocumentLength: Int? = null
private var completionPrevDocumentOffset: Int? = null private var completionPrevDocumentOffset: Int? = null
override fun beforeActionPerformed(action: AnAction, event: AnActionEvent) { override fun beforeActionPerformed(action: AnAction, event: AnActionEvent) {
@@ -64,6 +65,7 @@ internal object IdeaSpecifics {
val hostEditor = event.dataContext.getData(CommonDataKeys.HOST_EDITOR) val hostEditor = event.dataContext.getData(CommonDataKeys.HOST_EDITOR)
if (hostEditor != null) { if (hostEditor != null) {
editor = hostEditor editor = hostEditor
caretOffset = hostEditor.caretModel.offset
} }
val isVimAction = (action as? AnActionWrapper)?.delegate is VimShortcutKeyAction val isVimAction = (action as? AnActionWrapper)?.delegate is VimShortcutKeyAction
@@ -95,7 +97,8 @@ internal object IdeaSpecifics {
if (VimPlugin.isNotEnabled()) return if (VimPlugin.isNotEnabled()) return
val editor = editor val editor = editor
if (editor != null && action is ChooseItemAction && editor.vimStateMachine?.isRecording == true) { if (editor != null) {
if (action is ChooseItemAction && editor.vimStateMachine?.isRecording == true) {
val prevDocumentLength = completionPrevDocumentLength val prevDocumentLength = completionPrevDocumentLength
val prevDocumentOffset = completionPrevDocumentOffset val prevDocumentOffset = completionPrevDocumentOffset
@@ -122,16 +125,20 @@ internal object IdeaSpecifics {
) )
} }
) { ) {
editor?.let { val commandState = editor.vim.vimStateMachine
val commandState = it.vim.vimStateMachine
commandState.mode = Mode.NORMAL() commandState.mode = Mode.NORMAL()
VimPlugin.getChange().insertBeforeCursor(it.vim, event.dataContext.vim) VimPlugin.getChange().insertBeforeCursor(editor.vim, event.dataContext.vim)
KeyHandler.getInstance().reset(it.vim) KeyHandler.getInstance().reset(editor.vim)
}
} }
//endregion //endregion
if (caretOffset != -1 && caretOffset != editor.caretModel.offset) {
injector.scroll.scrollCaretIntoView(editor.vim)
}
}
this.editor = null this.editor = null
this.caretOffset = -1
} }
} }