mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-10 03:34:06 +02:00
Select trailing whitespace with vaw
Outer word/WORD motions will select trailing whitespace at the end of a line
This commit is contained in:
parent
4240c429ba
commit
81e094ac8f
src/test/java/org/jetbrains/plugins/ideavim/action
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api
@ -476,7 +476,7 @@ $c tw${c}o
|
||||
injector.parser.parseKeys("v" + "aW"),
|
||||
" a${c}bcd${c}e.abcde.a${c}bcde a${c}bcde.abcde \n",
|
||||
)
|
||||
assertState(" <selection>abcde.abcde.abcde </selection><selection>abcde.abcde</selection> \n")
|
||||
assertState(" <selection>abcde.abcde.abcde </selection><selection>abcde.abcde </selection>\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -1077,7 +1077,7 @@ $c tw${c}o
|
||||
injector.parser.parseKeys("v" + "aW" + "l" + "h"),
|
||||
"a${c}bcde.abcde.abcde ab${c}cde.abcde \n",
|
||||
)
|
||||
assertState("<selection>abcde.abcde.abcde abcde.abcde</selection> \n")
|
||||
assertState("<selection>abcde.abcde.abcde abcde.abcde </selection>\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -168,16 +168,6 @@ class MotionOuterBigWordActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(originalVimAfter =
|
||||
"""
|
||||
|Lorem Ipsum
|
||||
|
|
||||
|Lorem ipsum dolor sit amet,
|
||||
|${s}consectetur adipiscing elit.......${c}.${se}
|
||||
|Sed in orci mauris.
|
||||
|Cras id tellus in ex imperdiet egestas.
|
||||
"""
|
||||
)
|
||||
@Test
|
||||
fun `test repeated text object expands selection to whitespace at end of line`() {
|
||||
doTest(
|
||||
@ -194,7 +184,7 @@ class MotionOuterBigWordActionTest : VimTestCase() {
|
||||
|Lorem Ipsum
|
||||
|
|
||||
|Lorem ipsum dolor sit amet,
|
||||
|${s}consectetur adipiscing eli${c}t${se}........
|
||||
|${s}consectetur adipiscing elit.......${c}.${se}
|
||||
|Sed in orci mauris.
|
||||
|Cras id tellus in ex imperdiet egestas.
|
||||
""".trimMargin().dotToSpace(),
|
||||
@ -467,6 +457,11 @@ class MotionOuterBigWordActionTest : VimTestCase() {
|
||||
doTest("vaW", " Lor${c}em", " ${s}Lore${c}m${se}", Mode.VISUAL(SelectionType.CHARACTER_WISE))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test select outer WORD on last word on line selects trailing whitespace`() {
|
||||
doTest("vaW", " Lor${c}em ", " ${s}Lorem ${c} ${se}", Mode.VISUAL(SelectionType.CHARACTER_WISE))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test select outer WORD with existing left-to-right selection selects rest of word and following whitespace`() {
|
||||
doTest(
|
||||
@ -477,6 +472,16 @@ class MotionOuterBigWordActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test select outer WORD with existing left-to-right selection selects rest of word and trailing whitespace at end of line`() {
|
||||
doTest(
|
||||
listOf("v", "l", "aW"),
|
||||
"Lo${c}rem ",
|
||||
"Lo${s}rem ${c} ${se}",
|
||||
Mode.VISUAL(SelectionType.CHARACTER_WISE),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test select outer WORD with existing left-to-right selection in whitespace selects rest of whitespace and following word`() {
|
||||
doTest(
|
||||
|
@ -166,16 +166,6 @@ class MotionOuterWordActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@VimBehaviorDiffers(originalVimAfter =
|
||||
"""
|
||||
|Lorem Ipsum
|
||||
|
|
||||
|Lorem ipsum dolor sit amet,
|
||||
|${s}consectetur adipiscing elit.......${c}.${se}
|
||||
|Sed in orci mauris.
|
||||
|Cras id tellus in ex imperdiet egestas.
|
||||
"""
|
||||
)
|
||||
@Test
|
||||
fun `test repeated text object expands selection to whitespace at end of line`() {
|
||||
doTest(
|
||||
@ -192,7 +182,7 @@ class MotionOuterWordActionTest : VimTestCase() {
|
||||
|Lorem Ipsum
|
||||
|
|
||||
|Lorem ipsum dolor sit amet,
|
||||
|${s}consectetur adipiscing eli${c}t${se}........
|
||||
|${s}consectetur adipiscing elit.......${c}.${se}
|
||||
|Sed in orci mauris.
|
||||
|Cras id tellus in ex imperdiet egestas.
|
||||
""".trimMargin().dotToSpace(),
|
||||
@ -474,6 +464,11 @@ class MotionOuterWordActionTest : VimTestCase() {
|
||||
doTest("vaw", " Lor${c}em", " ${s}Lore${c}m${se}", Mode.VISUAL(SelectionType.CHARACTER_WISE))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test select outer word on last word on line selects trailing whitespace`() {
|
||||
doTest("vaw", " Lor${c}em ", " ${s}Lorem ${c} ${se}", Mode.VISUAL(SelectionType.CHARACTER_WISE))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test select outer word with existing left-to-right selection selects rest of word and following whitespace`() {
|
||||
doTest(
|
||||
@ -484,6 +479,16 @@ class MotionOuterWordActionTest : VimTestCase() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test select outer word with existing left-to-right selection selects rest of word and trailing whitespace at end of line`() {
|
||||
doTest(
|
||||
listOf("v", "l", "aw"),
|
||||
"Lo${c}rem ",
|
||||
"Lo${s}rem ${c} ${se}",
|
||||
Mode.VISUAL(SelectionType.CHARACTER_WISE),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test select outer word with existing left-to-right selection in whitespace selects rest of whitespace and following word`() {
|
||||
doTest(
|
||||
|
@ -1484,10 +1484,11 @@ abstract class VimSearchHelperBase : VimSearchHelper {
|
||||
logger.debug("goForward=$goForward")
|
||||
|
||||
if (goForward) {
|
||||
if (editor.anyNonWhitespace(end, 1)) {
|
||||
while (end + 1 < max && charType(editor, chars[end + 1], false) === CharacterHelper.CharacterType.WHITESPACE) {
|
||||
end++
|
||||
}
|
||||
while (end + 1 < max
|
||||
&& chars[end + 1] != '\n'
|
||||
&& charType(editor, chars[end + 1], false) === CharacterHelper.CharacterType.WHITESPACE
|
||||
) {
|
||||
end++
|
||||
}
|
||||
}
|
||||
if (goBack) {
|
||||
|
Loading…
Reference in New Issue
Block a user