1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-04-25 19:15:45 +02:00

Fix incorrectly selected new line char with viw

This commit is contained in:
Matt Ellis 2025-01-29 09:45:30 +00:00 committed by Alex Pláte
parent 18b4b76ebf
commit 960eb50d8c
3 changed files with 9 additions and 44 deletions
src/test/java/org/jetbrains/plugins/ideavim/action/motion/object
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api

View File

@ -551,22 +551,10 @@ class MotionInnerBigWordActionTest : VimTestCase() {
)
}
// TODO: Fix this bug
@VimBehaviorDiffers(originalVimAfter =
"""
|Lorem Ipsum
|
|Lorem ipsum dolor sit amet,
|consectetur adipiscing ${s}elit
|Se${c}d${se} in orci mauris.
|Cras id tellus in ex imperdiet egestas.
""",
description = "IdeaVim expands to include newline character"
)
@Test
fun `test repeated text object expands across new line`() {
doTest(
listOf("viW", "iW", "iW"), // TODO: This should be just listOf("viW", "iW")
listOf("viW", "iW"),
"""
|Lorem Ipsum
|
@ -796,14 +784,6 @@ class MotionInnerBigWordActionTest : VimTestCase() {
)
}
// TODO: Fix this bug
@VimBehaviorDiffers(originalVimAfter =
"""
|Lorem ipsum dolor sit amet, consectetur adipiscing ${s}elit
|Sed${c} ${se}in orci mauris. Cras id tellus in ex imperdiet egestas.
""",
description = "Unclear why this fails. IdeaVim seems to treat the new line char as a word"
)
@Test
fun `test select multiple words wraps to next line`() {
doTest(
@ -814,7 +794,7 @@ class MotionInnerBigWordActionTest : VimTestCase() {
""".trimMargin(),
"""
|Lorem ipsum dolor sit amet, consectetur adipiscing ${s}elit
|Se${c}d${se} in orci mauris. Cras id tellus in ex imperdiet egestas.
|Sed${c} ${se}in orci mauris. Cras id tellus in ex imperdiet egestas.
""".trimMargin(),
Mode.VISUAL(SelectionType.CHARACTER_WISE),
)

View File

@ -551,22 +551,10 @@ class MotionInnerWordActionTest : VimTestCase() {
)
}
// TODO: Fix this bug
@VimBehaviorDiffers(originalVimAfter =
"""
|Lorem Ipsum
|
|Lorem ipsum dolor sit amet,
|consectetur adipiscing ${s}elit
|Se${c}d${se} in orci mauris.
|Cras id tellus in ex imperdiet egestas.
""",
description = "IdeaVim expands to include newline character"
)
@Test
fun `test repeated text object expands across new line`() {
doTest(
listOf("viw", "iw", "iw"), // TODO: This should be just listOf("viw", "iw")
listOf("viw", "iw"),
"""
|Lorem Ipsum
|
@ -816,14 +804,6 @@ class MotionInnerWordActionTest : VimTestCase() {
)
}
// TODO: Fix this bug
@VimBehaviorDiffers(originalVimAfter =
"""
|Lorem ipsum dolor sit amet, consectetur adipiscing ${s}elit
|Sed${c} ${se}in orci mauris. Cras id tellus in ex imperdiet egestas.
""",
description = "Unclear why this fails. IdeaVim seems to treat the new line char as a word"
)
@Test
fun `test select multiple words wraps to next line`() {
doTest(
@ -834,7 +814,7 @@ class MotionInnerWordActionTest : VimTestCase() {
""".trimMargin(),
"""
|Lorem ipsum dolor sit amet, consectetur adipiscing ${s}elit
|Se${c}d${se} in orci mauris. Cras id tellus in ex imperdiet egestas.
|Sed${c} ${se}in orci mauris. Cras id tellus in ex imperdiet egestas.
""".trimMargin(),
Mode.VISUAL(SelectionType.CHARACTER_WISE),
)

View File

@ -389,6 +389,11 @@ abstract class VimSearchHelperBase : VimSearchHelper {
var found = false
// For forward searches, skip any current whitespace so we start at the start of a word
if (step > 0 && pos < size - 1) {
if (chars[pos + 1] == '\n'
&& spaceWords
&& charType(editor, chars[pos], bigWord) !== charType(editor, chars[pos + 1], bigWord)) {
pos++
}
if (charType(editor, chars[pos + 1], bigWord) === CharacterHelper.CharacterType.WHITESPACE && !spaceWords) {
pos = skipSpace(editor, chars, pos + 1, step, size, false) - 1
}