mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2026-10-17 05:33:52 +02:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
975bead6f8
|
@@ -12,6 +12,7 @@ import com.intellij.vim.api.VimApi
|
||||
import com.intellij.vim.api.VimInitApi
|
||||
import com.intellij.vim.api.getVariable
|
||||
import com.intellij.vim.api.scopes.nmapPluginAction
|
||||
import com.intellij.vim.api.scopes.omapPluginAction
|
||||
import com.intellij.vim.api.scopes.xmapPluginAction
|
||||
import com.maddyhome.idea.vim.extension.VimExtension
|
||||
|
||||
@@ -32,12 +33,12 @@ internal class ParagraphMotion : VimExtension {
|
||||
xmapPluginAction("{", "<Plug>(ParagraphPrevMotion)", keepDefaultMapping = true) {
|
||||
moveParagraph(-1)
|
||||
}
|
||||
// omapPluginAction("}", "<Plug>(ParagraphNextMotion)", keepDefaultMapping = true) {
|
||||
// moveParagraph(1)
|
||||
// }
|
||||
// omapPluginAction("{", "<Plug>(ParagraphPrevMotion)", keepDefaultMapping = true) {
|
||||
// moveParagraph(-1)
|
||||
// }
|
||||
omapPluginAction("}", "<Plug>(ParagraphNextMotion)", keepDefaultMapping = true) {
|
||||
moveParagraph(1)
|
||||
}
|
||||
omapPluginAction("{", "<Plug>(ParagraphPrevMotion)", keepDefaultMapping = true) {
|
||||
moveParagraph(-1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-8
@@ -24,7 +24,7 @@ import com.maddyhome.idea.vim.handler.toMotionOrError
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import java.util.*
|
||||
|
||||
sealed class MotionUnmatchedAction(private val motionChar: Char, private val isBackwardsMotion: Boolean) : MotionActionHandler.ForEachCaret() {
|
||||
sealed class MotionUnmatchedAction(private val motionChar: Char) : MotionActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_SAVE_JUMP)
|
||||
|
||||
override val motionType: MotionType = MotionType.EXCLUSIVE
|
||||
@@ -36,9 +36,7 @@ sealed class MotionUnmatchedAction(private val motionChar: Char, private val isB
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Motion {
|
||||
return moveCaretToUnmatchedBlock(editor, caret, operatorArguments.count1, motionChar)
|
||||
?.let { if (isBackwardsMotion) it + 1 else it }
|
||||
?.toMotionOrError()
|
||||
return moveCaretToUnmatchedBlock(editor, caret, operatorArguments.count1, motionChar)?.toMotionOrError()
|
||||
?: Motion.Error
|
||||
}
|
||||
}
|
||||
@@ -48,28 +46,28 @@ sealed class MotionUnmatchedAction(private val motionChar: Char, private val isB
|
||||
modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING],
|
||||
description = "Go to the [count]'th next unmatched '}'."
|
||||
)
|
||||
class MotionUnmatchedBraceCloseAction : MotionUnmatchedAction('}', isBackwardsMotion = false)
|
||||
class MotionUnmatchedBraceCloseAction : MotionUnmatchedAction('}')
|
||||
|
||||
@CommandOrMotion(
|
||||
keys = ["[{"],
|
||||
modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING],
|
||||
description = "Go to the [count]'th previous unmatched '{'."
|
||||
)
|
||||
class MotionUnmatchedBraceOpenAction : MotionUnmatchedAction('{', isBackwardsMotion = true)
|
||||
class MotionUnmatchedBraceOpenAction : MotionUnmatchedAction('{')
|
||||
|
||||
@CommandOrMotion(
|
||||
keys = ["])"],
|
||||
modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING],
|
||||
description = "Go to the [count]'th next unmatched ')'."
|
||||
)
|
||||
class MotionUnmatchedParenCloseAction : MotionUnmatchedAction(')', isBackwardsMotion = false)
|
||||
class MotionUnmatchedParenCloseAction : MotionUnmatchedAction(')')
|
||||
|
||||
@CommandOrMotion(
|
||||
keys = ["[("],
|
||||
modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING],
|
||||
description = "Go to the [count]'th previous unmatched '('."
|
||||
)
|
||||
class MotionUnmatchedParenOpenAction : MotionUnmatchedAction('(', isBackwardsMotion = true)
|
||||
class MotionUnmatchedParenOpenAction : MotionUnmatchedAction('(')
|
||||
|
||||
private fun moveCaretToUnmatchedBlock(editor: VimEditor, caret: ImmutableVimCaret, count: Int, type: Char): Int? {
|
||||
return if (editor.currentCaret().offset == 0 && count < 0 || editor.currentCaret().offset >= editor.fileSize() - 1 && count > 0) {
|
||||
|
||||
Reference in New Issue
Block a user