mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-11 15:34:06 +02:00
VIM-566: Add za motion support for toggling folds
This commit is contained in:
parent
2189b70b87
commit
3ba14d05b4
src/main/java/com/maddyhome/idea/vim/helper
tests/java-tests/src/test/kotlin/org/jetbrains/plugins/ideavim/action
vim-engine/src/main/kotlin/com/maddyhome/idea/vim
@ -60,6 +60,8 @@ internal class IjActionExecutor : VimActionExecutor {
|
||||
get() = IdeActions.ACTION_EXPAND_REGION
|
||||
override val ACTION_EXPAND_REGION_RECURSIVELY: String
|
||||
get() = IdeActions.ACTION_EXPAND_REGION_RECURSIVELY
|
||||
override val ACTION_EXPAND_COLLAPSE_TOGGLE: String
|
||||
get() = "ExpandCollapseToggleAction"
|
||||
|
||||
/**
|
||||
* Execute an action
|
||||
|
@ -16,6 +16,7 @@ import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimBehaviorDiffers
|
||||
import org.jetbrains.plugins.ideavim.VimJavaTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class ChangeActionJavaTest : VimJavaTestCase() {
|
||||
// VIM-511 |.|
|
||||
@ -120,6 +121,28 @@ and some text after""",
|
||||
)
|
||||
}
|
||||
|
||||
// VIM-566
|
||||
@TestWithoutNeovim(SkipNeovimReason.FOLDING)
|
||||
@Test
|
||||
fun testInsertAfterToggleFold() {
|
||||
configureByJavaText(
|
||||
"""
|
||||
$c/**
|
||||
* I should be fold
|
||||
* a little more text
|
||||
* and final fold
|
||||
*/
|
||||
and some text after
|
||||
""".trimIndent(),
|
||||
)
|
||||
CodeFoldingManager.getInstance(fixture.project).updateFoldRegions(fixture.editor)
|
||||
assertEquals(FoldingUtil.findFoldRegionStartingAtLine(fixture.editor, 0)!!.isExpanded, true)
|
||||
typeText(injector.parser.parseKeys("za"))
|
||||
assertEquals(FoldingUtil.findFoldRegionStartingAtLine(fixture.editor, 0)!!.isExpanded, false)
|
||||
typeText(injector.parser.parseKeys("za"))
|
||||
assertEquals(FoldingUtil.findFoldRegionStartingAtLine(fixture.editor, 0)!!.isExpanded, true)
|
||||
}
|
||||
|
||||
// VIM-287 |zc| |o|
|
||||
@TestWithoutNeovim(SkipNeovimReason.FOLDING)
|
||||
@Test
|
||||
|
@ -33,6 +33,22 @@ class VimCollapseAllRegions : VimActionHandler.SingleExecution() {
|
||||
}
|
||||
}
|
||||
|
||||
@CommandOrMotion(keys = ["za"], modes = [Mode.NORMAL, Mode.VISUAL])
|
||||
class VimExpandCollapseToggleRegion : VimActionHandler.SingleExecution() {
|
||||
|
||||
override val type: Command.Type = Command.Type.OTHER_READONLY
|
||||
|
||||
override fun execute(
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
injector.actionExecutor.executeAction(editor, name = injector.actionExecutor.ACTION_EXPAND_COLLAPSE_TOGGLE, context = context)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@CommandOrMotion(keys = ["zc"], modes = [Mode.NORMAL, Mode.VISUAL])
|
||||
class VimCollapseRegion : VimActionHandler.SingleExecution() {
|
||||
|
||||
|
@ -20,6 +20,7 @@ interface VimActionExecutor {
|
||||
val ACTION_EXPAND_ALL_REGIONS: String
|
||||
val ACTION_EXPAND_REGION: String
|
||||
val ACTION_EXPAND_REGION_RECURSIVELY: String
|
||||
val ACTION_EXPAND_COLLAPSE_TOGGLE: String
|
||||
|
||||
/**
|
||||
* Execute an action
|
||||
|
Loading…
Reference in New Issue
Block a user