mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-01 15:59:06 +02:00
Add support for key in selectmode option
This commit is contained in:
parent
2ad4436cef
commit
fe01820f3f
src/com/maddyhome/idea/vim/action/motion/leftright
test/org/jetbrains/plugins/ideavim/action/motion/leftright
@ -37,9 +37,14 @@ import javax.swing.KeyStroke
|
||||
private object MotionShiftDownActionHandler : EditorActionHandlerBase() {
|
||||
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
|
||||
if (Options.getInstance().getListOption(Options.KEYMODEL)?.contains("startsel") == true) {
|
||||
if (!CommandState.inVisualMode(editor)) {
|
||||
VimPlugin.getVisualMotion()
|
||||
.toggleVisual(editor, 1, 0, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
@Suppress("DuplicatedCode")
|
||||
if (!CommandState.inVisualMode(editor) && !CommandState.inSelectMode(editor)) {
|
||||
if (Options.getInstance().getListOption(Options.SELECTMODE)?.contains("key") == true) {
|
||||
VimPlugin.getVisualMotion().enterSelectMode(editor, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
} else {
|
||||
VimPlugin.getVisualMotion()
|
||||
.toggleVisual(editor, 1, 0, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
}
|
||||
}
|
||||
editor.caretModel.allCarets.forEach { caret ->
|
||||
val vertical = VimPlugin.getMotion().moveCaretVertical(editor, caret, cmd.count)
|
||||
|
@ -38,9 +38,14 @@ import javax.swing.KeyStroke
|
||||
private object MotionShiftLeftActionHandler : EditorActionHandlerBase() {
|
||||
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
|
||||
if (Options.getInstance().getListOption(Options.KEYMODEL)?.contains("startsel") == true) {
|
||||
if (!CommandState.inVisualMode(editor)) {
|
||||
VimPlugin.getVisualMotion()
|
||||
.toggleVisual(editor, 1, 0, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
@Suppress("DuplicatedCode")
|
||||
if (!CommandState.inVisualMode(editor) && !CommandState.inSelectMode(editor)) {
|
||||
if (Options.getInstance().getListOption(Options.SELECTMODE)?.contains("key") == true) {
|
||||
VimPlugin.getVisualMotion().enterSelectMode(editor, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
} else {
|
||||
VimPlugin.getVisualMotion()
|
||||
.toggleVisual(editor, 1, 0, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
}
|
||||
}
|
||||
editor.caretModel.allCarets.forEach { caret ->
|
||||
val vertical = VimPlugin.getMotion().moveCaretHorizontal(editor, caret, -cmd.count, true)
|
||||
|
@ -38,9 +38,14 @@ import javax.swing.KeyStroke
|
||||
private object MotionShiftRightActionHandler : EditorActionHandlerBase() {
|
||||
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
|
||||
if (Options.getInstance().getListOption(Options.KEYMODEL)?.contains("startsel") == true) {
|
||||
if (!CommandState.inVisualMode(editor)) {
|
||||
VimPlugin.getVisualMotion()
|
||||
.toggleVisual(editor, 1, 0, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
@Suppress("DuplicatedCode")
|
||||
if (!CommandState.inVisualMode(editor) && !CommandState.inSelectMode(editor)) {
|
||||
if (Options.getInstance().getListOption(Options.SELECTMODE)?.contains("key") == true) {
|
||||
VimPlugin.getVisualMotion().enterSelectMode(editor, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
} else {
|
||||
VimPlugin.getVisualMotion()
|
||||
.toggleVisual(editor, 1, 0, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
}
|
||||
}
|
||||
editor.caretModel.allCarets.forEach { caret ->
|
||||
val vertical = VimPlugin.getMotion().moveCaretHorizontal(editor, caret, cmd.count, true)
|
||||
|
@ -37,9 +37,14 @@ import javax.swing.KeyStroke
|
||||
private object MotionShiftUpActionHandler : EditorActionHandlerBase() {
|
||||
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
|
||||
if (Options.getInstance().getListOption(Options.KEYMODEL)?.contains("startsel") == true) {
|
||||
if (!CommandState.inVisualMode(editor)) {
|
||||
VimPlugin.getVisualMotion()
|
||||
.toggleVisual(editor, 1, 0, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
@Suppress("DuplicatedCode")
|
||||
if (!CommandState.inVisualMode(editor) && !CommandState.inSelectMode(editor)) {
|
||||
if (Options.getInstance().getListOption(Options.SELECTMODE)?.contains("key") == true) {
|
||||
VimPlugin.getVisualMotion().enterSelectMode(editor, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
} else {
|
||||
VimPlugin.getVisualMotion()
|
||||
.toggleVisual(editor, 1, 0, CommandState.SubMode.VISUAL_CHARACTER)
|
||||
}
|
||||
}
|
||||
editor.caretModel.allCarets.forEach { caret ->
|
||||
val vertical = VimPlugin.getMotion().moveCaretVertical(editor, caret, -cmd.count)
|
||||
|
@ -16,6 +16,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@file:Suppress("RemoveCurlyBracesFromTemplate")
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.motion.leftright
|
||||
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
@ -78,4 +80,66 @@ class MotionShiftDownActionHandlerTest : VimTestCase() {
|
||||
CommandState.Mode.VISUAL, CommandState.SubMode.VISUAL_CHARACTER
|
||||
)
|
||||
}
|
||||
|
||||
fun `test select down`() {
|
||||
Options.getInstance().getListOption(Options.KEYMODEL)?.set("startsel") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
Options.getInstance().getListOption(Options.SELECTMODE)?.set("key") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
|
||||
doTest(parseKeys("<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(),
|
||||
CommandState.Mode.SELECT, CommandState.SubMode.VISUAL_CHARACTER
|
||||
)
|
||||
}
|
||||
|
||||
fun `test select down twice`() {
|
||||
Options.getInstance().getListOption(Options.KEYMODEL)?.set("startsel") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
Options.getInstance().getListOption(Options.SELECTMODE)?.set("key") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
|
||||
doTest(parseKeys("<S-Down><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
|
||||
all rocks and lavender and tufted grass,
|
||||
wh${c}${se}ere it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
CommandState.Mode.SELECT, CommandState.SubMode.VISUAL_CHARACTER
|
||||
)
|
||||
}
|
||||
}
|
@ -80,4 +80,66 @@ class MotionShiftLeftActionHandlerTest : VimTestCase() {
|
||||
CommandState.Mode.VISUAL, CommandState.SubMode.VISUAL_CHARACTER
|
||||
)
|
||||
}
|
||||
|
||||
fun `test select left`() {
|
||||
Options.getInstance().getListOption(Options.KEYMODEL)?.set("startsel") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
Options.getInstance().getListOption(Options.SELECTMODE)?.set("key") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
|
||||
doTest(parseKeys("<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(),
|
||||
CommandState.Mode.SELECT, CommandState.SubMode.VISUAL_CHARACTER
|
||||
)
|
||||
}
|
||||
|
||||
fun `test select left twice`() {
|
||||
Options.getInstance().getListOption(Options.KEYMODEL)?.set("startsel") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
Options.getInstance().getListOption(Options.SELECTMODE)?.set("key") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
|
||||
doTest(parseKeys("<S-Left><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 fo${s}${c}un${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(),
|
||||
CommandState.Mode.SELECT, CommandState.SubMode.VISUAL_CHARACTER
|
||||
)
|
||||
}
|
||||
}
|
@ -78,4 +78,66 @@ class MotionShiftRightActionHandlerTest : VimTestCase() {
|
||||
CommandState.Mode.VISUAL, CommandState.SubMode.VISUAL_CHARACTER
|
||||
)
|
||||
}
|
||||
|
||||
fun `test select right`() {
|
||||
Options.getInstance().getListOption(Options.KEYMODEL)?.set("startsel") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
Options.getInstance().getListOption(Options.SELECTMODE)?.set("key") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
|
||||
doTest(parseKeys("<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(),
|
||||
CommandState.Mode.SELECT, CommandState.SubMode.VISUAL_CHARACTER
|
||||
)
|
||||
}
|
||||
|
||||
fun `test select right twice`() {
|
||||
Options.getInstance().getListOption(Options.KEYMODEL)?.set("startsel") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
Options.getInstance().getListOption(Options.SELECTMODE)?.set("key") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
|
||||
doTest(parseKeys("<S-Right><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}fo${c}${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(),
|
||||
CommandState.Mode.SELECT, CommandState.SubMode.VISUAL_CHARACTER
|
||||
)
|
||||
}
|
||||
}
|
@ -16,6 +16,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@file:Suppress("RemoveCurlyBracesFromTemplate")
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.motion.leftright
|
||||
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
@ -78,4 +80,66 @@ class MotionShiftUpActionHandlerTest : VimTestCase() {
|
||||
CommandState.Mode.VISUAL, CommandState.SubMode.VISUAL_CHARACTER
|
||||
)
|
||||
}
|
||||
|
||||
fun `test select up`() {
|
||||
Options.getInstance().getListOption(Options.KEYMODEL)?.set("startsel") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
Options.getInstance().getListOption(Options.SELECTMODE)?.set("key") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
|
||||
doTest(parseKeys("<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(),
|
||||
CommandState.Mode.SELECT, CommandState.SubMode.VISUAL_CHARACTER
|
||||
)
|
||||
}
|
||||
|
||||
fun `test select up twice`() {
|
||||
Options.getInstance().getListOption(Options.KEYMODEL)?.set("startsel") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
Options.getInstance().getListOption(Options.SELECTMODE)?.set("key") ?: run {
|
||||
TestCase.fail()
|
||||
return
|
||||
}
|
||||
|
||||
doTest(parseKeys("<S-Up><S-Up>"),
|
||||
"""
|
||||
A Discovery
|
||||
|
||||
I found it in a legendary land
|
||||
all rocks and lavender and tufted grass,
|
||||
wh${c}ere 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 rocks and lavender and tufted grass,
|
||||
wh${se}ere it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
CommandState.Mode.SELECT, CommandState.SubMode.VISUAL_CHARACTER
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user