1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-02-26 05:46:00 +01:00

Fix(VIM-2675): Fix numbering register in visual mode

This commit is contained in:
Alex Plate 2022-06-13 12:52:05 +03:00
parent 38ed9c206a
commit 072449825c
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
2 changed files with 33 additions and 1 deletions
src/test/java/org/jetbrains/plugins/ideavim/action/copy
vim-engine/src/main/kotlin/com/maddyhome/idea/vim

View File

@ -271,6 +271,38 @@ class YankVisualActionTest : VimTestCase() {
)
}
fun `test yank to numbered register in visual`() {
doTest(
injector.parser.parseKeys("ve" + "\"2y"),
"""
A Discovery
I found it in a legendary land
all ${c}rocks and lavender and tufted grass,[ additional symbols]
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent(),
"rocks",
SelectionType.CHARACTER_WISE
)
}
fun `test yank to numbered register`() {
doTest(
injector.parser.parseKeys("\"2yy"),
"""
A Discovery
I found it in a legendary land
all ${c}rocks and lavender and tufted grass,[ additional symbols]
where it was settled on some sodden sand
hard by the torrent of a mountain pass.
""".trimIndent(),
"all rocks and lavender and tufted grass,[ additional symbols]\n",
SelectionType.LINE_WISE
)
}
private fun doTest(keys: List<KeyStroke>, before: String, expectedText: String, expectedType: SelectionType) {
configureByText(before)
typeText(keys)

View File

@ -496,7 +496,7 @@ class KeyHandler {
// Make sure to avoid handling '0' as the start of a count.
val commandBuilder = editorState.commandBuilder
val notRegisterPendingCommand = editorState.mode.inNormalMode && !editorState.isRegisterPending
val visualMode = editorState.mode.inVisualMode
val visualMode = editorState.mode.inVisualMode && !editorState.isRegisterPending
val opPendingMode = editorState.mode === CommandState.Mode.OP_PENDING
if (notRegisterPendingCommand || visualMode || opPendingMode) {