Compare commits

..
Author SHA1 Message Date
chylex 975bead6f8 Set plugin version to 62 2026-10-14 20:47:01 +02:00
2 changed files with 13 additions and 14 deletions
@@ -12,6 +12,7 @@ import com.intellij.vim.api.VimApi
import com.intellij.vim.api.VimInitApi import com.intellij.vim.api.VimInitApi
import com.intellij.vim.api.getVariable import com.intellij.vim.api.getVariable
import com.intellij.vim.api.scopes.nmapPluginAction import com.intellij.vim.api.scopes.nmapPluginAction
import com.intellij.vim.api.scopes.omapPluginAction
import com.intellij.vim.api.scopes.xmapPluginAction import com.intellij.vim.api.scopes.xmapPluginAction
import com.maddyhome.idea.vim.extension.VimExtension import com.maddyhome.idea.vim.extension.VimExtension
@@ -32,12 +33,12 @@ internal class ParagraphMotion : VimExtension {
xmapPluginAction("{", "<Plug>(ParagraphPrevMotion)", keepDefaultMapping = true) { xmapPluginAction("{", "<Plug>(ParagraphPrevMotion)", keepDefaultMapping = true) {
moveParagraph(-1) moveParagraph(-1)
} }
// omapPluginAction("}", "<Plug>(ParagraphNextMotion)", keepDefaultMapping = true) { omapPluginAction("}", "<Plug>(ParagraphNextMotion)", keepDefaultMapping = true) {
// moveParagraph(1) moveParagraph(1)
// } }
// omapPluginAction("{", "<Plug>(ParagraphPrevMotion)", keepDefaultMapping = true) { omapPluginAction("{", "<Plug>(ParagraphPrevMotion)", keepDefaultMapping = true) {
// moveParagraph(-1) moveParagraph(-1)
// } }
} }
} }
} }
@@ -24,7 +24,7 @@ import com.maddyhome.idea.vim.handler.toMotionOrError
import com.maddyhome.idea.vim.helper.enumSetOf import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.* 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 flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_SAVE_JUMP)
override val motionType: MotionType = MotionType.EXCLUSIVE override val motionType: MotionType = MotionType.EXCLUSIVE
@@ -36,9 +36,7 @@ sealed class MotionUnmatchedAction(private val motionChar: Char, private val isB
argument: Argument?, argument: Argument?,
operatorArguments: OperatorArguments, operatorArguments: OperatorArguments,
): Motion { ): Motion {
return moveCaretToUnmatchedBlock(editor, caret, operatorArguments.count1, motionChar) return moveCaretToUnmatchedBlock(editor, caret, operatorArguments.count1, motionChar)?.toMotionOrError()
?.let { if (isBackwardsMotion) it + 1 else it }
?.toMotionOrError()
?: Motion.Error ?: Motion.Error
} }
} }
@@ -48,28 +46,28 @@ sealed class MotionUnmatchedAction(private val motionChar: Char, private val isB
modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING], modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING],
description = "Go to the [count]'th next unmatched '}'." description = "Go to the [count]'th next unmatched '}'."
) )
class MotionUnmatchedBraceCloseAction : MotionUnmatchedAction('}', isBackwardsMotion = false) class MotionUnmatchedBraceCloseAction : MotionUnmatchedAction('}')
@CommandOrMotion( @CommandOrMotion(
keys = ["[{"], keys = ["[{"],
modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING], modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING],
description = "Go to the [count]'th previous unmatched '{'." description = "Go to the [count]'th previous unmatched '{'."
) )
class MotionUnmatchedBraceOpenAction : MotionUnmatchedAction('{', isBackwardsMotion = true) class MotionUnmatchedBraceOpenAction : MotionUnmatchedAction('{')
@CommandOrMotion( @CommandOrMotion(
keys = ["])"], keys = ["])"],
modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING], modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING],
description = "Go to the [count]'th next unmatched ')'." description = "Go to the [count]'th next unmatched ')'."
) )
class MotionUnmatchedParenCloseAction : MotionUnmatchedAction(')', isBackwardsMotion = false) class MotionUnmatchedParenCloseAction : MotionUnmatchedAction(')')
@CommandOrMotion( @CommandOrMotion(
keys = ["[("], keys = ["[("],
modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING], modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING],
description = "Go to the [count]'th previous unmatched '('." 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? { 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) { return if (editor.currentCaret().offset == 0 && count < 0 || editor.currentCaret().offset >= editor.fileSize() - 1 && count > 0) {