mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-07 21:34:09 +02:00
Enter Insert Visual/Select mode with shifted key
This commit is contained in:
parent
da99e1f1c3
commit
2e0ef7e0b0
src/test/java/org/jetbrains/plugins/ideavim
action/motion
leftright
updown
command
vim-engine/src/main/kotlin/com/maddyhome/idea/vim
@ -79,6 +79,62 @@ class MotionShiftLeftActionHandlerTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [""]),
|
||||
)
|
||||
fun `test visual shift left in Insert enters Insert Visual mode`() {
|
||||
doTest(
|
||||
listOf("i<S-Left>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I foun${c}d it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I fou${s}${c}nd${se} it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.VISUAL(SelectionType.CHARACTER_WISE, returnTo = Mode.INSERT),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [""]),
|
||||
)
|
||||
fun `test visual shift left in Replace enters Replace Visual mode`() {
|
||||
doTest(
|
||||
listOf("R<S-Left>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I foun${c}d it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I fou${s}${c}nd${se} it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.VISUAL(SelectionType.CHARACTER_WISE, returnTo = Mode.REPLACE),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
@ -135,6 +191,62 @@ class MotionShiftLeftActionHandlerTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [OptionConstants.selectmode_key]),
|
||||
)
|
||||
fun `test select shift left in Insert enters Insert Visual mode`() {
|
||||
doTest(
|
||||
listOf("i<S-Left>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I foun${c}d it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I fou${s}${c}n${se}d it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.SELECT(SelectionType.CHARACTER_WISE, returnTo = Mode.INSERT),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [OptionConstants.selectmode_key]),
|
||||
)
|
||||
fun `test select shift left in Replace enters Replace Visual mode`() {
|
||||
doTest(
|
||||
listOf("R<S-Left>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I foun${c}d it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I fou${s}${c}n${se}d it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.SELECT(SelectionType.CHARACTER_WISE, returnTo = Mode.REPLACE),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_continueselect]),
|
||||
|
@ -79,6 +79,62 @@ class MotionShiftRightActionHandlerTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [""]),
|
||||
)
|
||||
fun `test visual shift right in Insert mode enters Insert Visual mode`() {
|
||||
doTest(
|
||||
listOf("i<S-Right>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${c}found it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${s}f${c}o${se}und it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.VISUAL(SelectionType.CHARACTER_WISE, returnTo = Mode.INSERT),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [""]),
|
||||
)
|
||||
fun `test visual shift right in Replace mode enters Replace Visual mode`() {
|
||||
doTest(
|
||||
listOf("R<S-Right>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${c}found it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${s}f${c}o${se}und it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.VISUAL(SelectionType.CHARACTER_WISE, returnTo = Mode.REPLACE),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
@ -135,6 +191,62 @@ class MotionShiftRightActionHandlerTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [OptionConstants.selectmode_key]),
|
||||
)
|
||||
fun `test select shift right in Insert enters Insert Select mode`() {
|
||||
doTest(
|
||||
listOf("i<S-Right>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${c}found it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${s}f${c}${se}ound it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.SELECT(SelectionType.CHARACTER_WISE, returnTo = Mode.INSERT),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [OptionConstants.selectmode_key]),
|
||||
)
|
||||
fun `test select shift right in Replace enters Replace Select mode`() {
|
||||
doTest(
|
||||
listOf("R<S-Right>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${c}found it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${s}f${c}${se}ound it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.SELECT(SelectionType.CHARACTER_WISE, returnTo = Mode.REPLACE),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_continueselect]),
|
||||
|
@ -107,6 +107,62 @@ class MotionShiftDownActionHandlerTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [""]),
|
||||
)
|
||||
fun `test Visual shift down in Insert mode enters Insert Visual mode`() {
|
||||
doTest(
|
||||
listOf("i<S-Down>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${c}found it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${s}found it in a legendary land
|
||||
al${c}l${se} rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.VISUAL(SelectionType.CHARACTER_WISE, returnTo = Mode.INSERT),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [""]),
|
||||
)
|
||||
fun `test Visual shift down in Replace mode enters Replace Visual mode`() {
|
||||
doTest(
|
||||
listOf("R<S-Down>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${c}found it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${s}found it in a legendary land
|
||||
al${c}l${se} rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.VISUAL(SelectionType.CHARACTER_WISE, returnTo = Mode.REPLACE),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
@ -163,6 +219,62 @@ class MotionShiftDownActionHandlerTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [OptionConstants.selectmode_key]),
|
||||
)
|
||||
fun `test Select shift down in Insert mode enters Insert Select mode`() {
|
||||
doTest(
|
||||
listOf("i<S-Down>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${c}found it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${s}found it in a legendary land
|
||||
al${c}${se}l rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.SELECT(SelectionType.CHARACTER_WISE, returnTo = Mode.INSERT),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [OptionConstants.selectmode_key]),
|
||||
)
|
||||
fun `test Select shift down in Replace mode enters Replace Select mode`() {
|
||||
doTest(
|
||||
listOf("R<S-Down>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${c}found it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${s}found it in a legendary land
|
||||
al${c}${se}l rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.SELECT(SelectionType.CHARACTER_WISE, returnTo = Mode.REPLACE),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_continueselect]),
|
||||
|
@ -107,6 +107,62 @@ class MotionShiftUpActionHandlerTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [""]),
|
||||
)
|
||||
fun `test Visual shift up in Insert mode enters Insert Visual mode`() {
|
||||
doTest(
|
||||
listOf("i<S-Up>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I found it in a legendary land
|
||||
al${c}l rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${s}${c}found it in a legendary land
|
||||
all${se} rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.VISUAL(SelectionType.CHARACTER_WISE, returnTo = Mode.INSERT),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [""]),
|
||||
)
|
||||
fun `test Visual shift up in Replace mode enters Replace Visual mode`() {
|
||||
doTest(
|
||||
listOf("R<S-Up>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I found it in a legendary land
|
||||
al${c}l rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${s}${c}found it in a legendary land
|
||||
all${se} rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.VISUAL(SelectionType.CHARACTER_WISE, returnTo = Mode.REPLACE),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
@ -163,6 +219,62 @@ class MotionShiftUpActionHandlerTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [OptionConstants.selectmode_key]),
|
||||
)
|
||||
fun `test Select shift up in Insert mode enters Insert Select mode`() {
|
||||
doTest(
|
||||
listOf("i<S-Up>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I found it in a legendary land
|
||||
al${c}l rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${s}${c}found it in a legendary land
|
||||
al${se}l rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.SELECT(SelectionType.CHARACTER_WISE, returnTo = Mode.INSERT),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_startsel]),
|
||||
VimOption(TestOptionConstants.selectmode, limitedValues = [OptionConstants.selectmode_key]),
|
||||
)
|
||||
fun `test Select shift up in Replace mode enters Replace Select mode`() {
|
||||
doTest(
|
||||
listOf("R<S-Up>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I found it in a legendary land
|
||||
al${c}l rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I ${s}${c}found it in a legendary land
|
||||
al${se}l rocks and lavender and tufted grass,
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
Mode.SELECT(SelectionType.CHARACTER_WISE, returnTo = Mode.REPLACE),
|
||||
)
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.OPTION)
|
||||
@OptionTest(
|
||||
VimOption(TestOptionConstants.keymodel, limitedValues = [OptionConstants.keymodel_continueselect]),
|
||||
|
@ -13,7 +13,6 @@ import com.maddyhome.idea.vim.ui.widgets.mode.VimModeWidget
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@ -170,8 +169,6 @@ class VimShowModeTest : VimTestCase() {
|
||||
assertEquals("(insert) SELECT", statusString)
|
||||
}
|
||||
|
||||
// TODO: Not currently working
|
||||
@Disabled
|
||||
@Test
|
||||
fun `test status string in Insert Select mode 2`() {
|
||||
configureByText("123")
|
||||
|
@ -17,7 +17,6 @@ import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.handler.VimActionHandler
|
||||
import com.maddyhome.idea.vim.helper.pushVisualMode
|
||||
import com.maddyhome.idea.vim.helper.setSelectMode
|
||||
import com.maddyhome.idea.vim.state.mode.SelectionType
|
||||
|
||||
/**
|
||||
@ -43,7 +42,7 @@ class SelectToggleVisualMode : VimActionHandler.SingleExecution() {
|
||||
fun toggleMode(editor: VimEditor) {
|
||||
val myMode = editor.mode
|
||||
if (myMode is com.maddyhome.idea.vim.state.mode.Mode.VISUAL) {
|
||||
editor.setSelectMode(myMode.selectionType)
|
||||
injector.visualMotionGroup.enterSelectMode(editor, myMode.selectionType)
|
||||
if (myMode.selectionType != SelectionType.LINE_WISE) {
|
||||
editor.nativeCarets().forEach {
|
||||
if (it.offset + injector.visualMotionGroup.selectionAdj == it.selectionEnd) {
|
||||
|
@ -32,8 +32,7 @@ class VisualToggleBlockModeAction : VimActionHandler.SingleExecution() {
|
||||
return if (injector.options(editor).selectmode.contains(OptionConstants.selectmode_cmd)) {
|
||||
injector.visualMotionGroup.enterSelectMode(editor, SelectionType.BLOCK_WISE)
|
||||
} else {
|
||||
injector.visualMotionGroup
|
||||
.toggleVisual(editor, cmd.count, cmd.rawCount, SelectionType.BLOCK_WISE)
|
||||
injector.visualMotionGroup.toggleVisual(editor, cmd.count, cmd.rawCount, SelectionType.BLOCK_WISE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,7 @@ class VisualToggleCharacterModeAction : VimActionHandler.SingleExecution() {
|
||||
return if (injector.options(editor).selectmode.contains(OptionConstants.selectmode_cmd)) {
|
||||
injector.visualMotionGroup.enterSelectMode(editor, SelectionType.CHARACTER_WISE)
|
||||
} else {
|
||||
injector.visualMotionGroup
|
||||
.toggleVisual(editor, cmd.count, cmd.rawCount, SelectionType.CHARACTER_WISE)
|
||||
injector.visualMotionGroup.toggleVisual(editor, cmd.count, cmd.rawCount, SelectionType.CHARACTER_WISE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,20 +18,32 @@ interface VimVisualMotionGroup {
|
||||
/**
|
||||
* This function toggles visual mode.
|
||||
*
|
||||
* If visual mode is disabled, enable it
|
||||
* If visual mode is enabled, but [selectionType] differs, update visual according to new [selectionType]
|
||||
* If visual mode is enabled with the same [selectionType], disable it
|
||||
* * If visual mode is disabled, enable it
|
||||
* * If visual mode is enabled, but [selectionType] differs, update visual according to new [selectionType]
|
||||
* * If visual mode is enabled with the same [selectionType], disable it
|
||||
*/
|
||||
fun toggleVisual(editor: VimEditor, count: Int, rawCount: Int, selectionType: SelectionType, returnTo: Mode? = null): Boolean
|
||||
fun enterSelectMode(editor: VimEditor, subMode: SelectionType): Boolean
|
||||
|
||||
/**
|
||||
* Enter Select mode with the given selection type
|
||||
*
|
||||
* When used from Normal, Insert or Replace modes, it will enter Select mode using the current mode as the "return to"
|
||||
* mode. I.e., if entered from Normal, will return to Normal. If entered from Insert or Replace (via shifted keys)
|
||||
* will return to Insert or Replace (aka "Insert Select" mode).
|
||||
*
|
||||
* While it will toggle between Visual and Select modes, it doesn't update the character positions correctly. IdeaVim
|
||||
* treats Select mode as exclusive and adjusts the character position when toggling modes.
|
||||
*/
|
||||
fun enterSelectMode(editor: VimEditor, selectionType: SelectionType): Boolean
|
||||
|
||||
/**
|
||||
* Enters visual mode based on current editor state.
|
||||
*
|
||||
* If [subMode] is null, subMode will be detected automatically
|
||||
*
|
||||
* it:
|
||||
* - Updates command state
|
||||
* - Updates [vimSelectionStart] property
|
||||
* - Updates [VimCaret.vimSelectionStart] property
|
||||
* - Updates caret colors
|
||||
* - Updates care shape
|
||||
*
|
||||
|
@ -15,7 +15,6 @@ import com.maddyhome.idea.vim.group.visual.vimSetSelection
|
||||
import com.maddyhome.idea.vim.group.visual.vimUpdateEditorSelection
|
||||
import com.maddyhome.idea.vim.helper.exitVisualMode
|
||||
import com.maddyhome.idea.vim.helper.pushVisualMode
|
||||
import com.maddyhome.idea.vim.helper.setSelectMode
|
||||
import com.maddyhome.idea.vim.state.mode.Mode
|
||||
import com.maddyhome.idea.vim.state.mode.SelectionType
|
||||
import com.maddyhome.idea.vim.state.mode.inVisualMode
|
||||
@ -27,8 +26,15 @@ abstract class VimVisualMotionGroupBase : VimVisualMotionGroup {
|
||||
override val selectionAdj: Int
|
||||
get() = if (exclusiveSelection) 0 else 1
|
||||
|
||||
override fun enterSelectMode(editor: VimEditor, subMode: SelectionType): Boolean {
|
||||
editor.setSelectMode(subMode)
|
||||
override fun enterSelectMode(editor: VimEditor, selectionType: SelectionType): Boolean {
|
||||
// If we're already in Select or toggling from Visual, replace the current mode (keep the existing returnTo),
|
||||
// otherwise push Select, using the current mode as returnTo.
|
||||
// If we're entering from Normal, use its own returnTo, as this will handle both Normal and "Internal Normal"
|
||||
editor.mode = when (editor.mode) {
|
||||
is Mode.SELECT, is Mode.VISUAL -> Mode.SELECT(selectionType, editor.mode.returnTo)
|
||||
is Mode.NORMAL -> Mode.SELECT(selectionType, editor.mode.returnTo)
|
||||
else -> Mode.SELECT(selectionType, editor.mode)
|
||||
}
|
||||
editor.forEachCaret { it.vimSelectionStart = it.vimLeadSelectionOffset }
|
||||
return true
|
||||
}
|
||||
@ -67,10 +73,7 @@ abstract class VimVisualMotionGroupBase : VimVisualMotionGroup {
|
||||
it.vimLastColumn = intendedColumn
|
||||
}
|
||||
} else {
|
||||
editor.mode = Mode.VISUAL(
|
||||
selectionType,
|
||||
returnTo ?: editor.mode.returnTo
|
||||
)
|
||||
editor.mode = Mode.VISUAL(selectionType, returnTo ?: editor.mode.returnTo)
|
||||
editor.forEachCaret { it.vimSetSelection(it.offset) }
|
||||
}
|
||||
return true
|
||||
|
@ -19,7 +19,6 @@ import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.helper.exitVisualMode
|
||||
import com.maddyhome.idea.vim.options.OptionConstants
|
||||
import com.maddyhome.idea.vim.state.mode.Mode
|
||||
import com.maddyhome.idea.vim.state.mode.SelectionType
|
||||
import com.maddyhome.idea.vim.state.mode.isInsertionAllowed
|
||||
import com.maddyhome.idea.vim.state.mode.inSelectMode
|
||||
@ -94,10 +93,12 @@ abstract class ShiftedArrowKeyHandler(private val runBothCommandsAsMulticaret: B
|
||||
if (withKey) {
|
||||
if (!inVisualMode && !inSelectMode) {
|
||||
if (injector.globalOptions().selectmode.contains(OptionConstants.selectmode_key)) {
|
||||
// Note that this will correctly choose either Select or Insert Select modes
|
||||
injector.visualMotionGroup.enterSelectMode(editor, SelectionType.CHARACTER_WISE)
|
||||
} else {
|
||||
if (editor.isInsertionAllowed) {
|
||||
injector.visualMotionGroup.toggleVisual(editor, 1, 0, SelectionType.CHARACTER_WISE, Mode.INSERT)
|
||||
// Enter Insert/Replace Visual mode
|
||||
injector.visualMotionGroup.toggleVisual(editor, 1, 0, SelectionType.CHARACTER_WISE, editor.mode)
|
||||
} else {
|
||||
injector.visualMotionGroup.toggleVisual(editor, 1, 0, SelectionType.CHARACTER_WISE)
|
||||
}
|
||||
|
@ -61,10 +61,6 @@ inline fun <reified T : Enum<T>> enumSetOf(vararg value: T): EnumSet<T> = when (
|
||||
else -> EnumSet.of(value[0], *value.slice(1..value.lastIndex).toTypedArray())
|
||||
}
|
||||
|
||||
fun VimEditor.setSelectMode(submode: SelectionType) {
|
||||
mode = Mode.SELECT(submode, mode.returnTo)
|
||||
}
|
||||
|
||||
fun VimEditor.pushVisualMode(submode: SelectionType) {
|
||||
mode = Mode.VISUAL(submode, mode.returnTo)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user