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

assuring that visual selection tokens belong to the same cursor

This commit is contained in:
Emanuel Gestosa 2023-09-13 16:06:20 +01:00 committed by lippfi
parent 008b3d94fb
commit e843d9e9c3
2 changed files with 22 additions and 2 deletions
vim-engine/src
main/kotlin/com/maddyhome/idea/vim/regexp/nfa/matcher
test/kotlin/com/maddyhome/idea/vim/regexp/internal

View File

@ -23,7 +23,13 @@ internal class VisualAreaMatcher : Matcher {
isCaseInsensitive: Boolean,
possibleCursors: MutableList<VimCaret>
): MatcherResult {
return if (index >= editor.currentCaret().selectionStart && index < editor.currentCaret().selectionEnd) MatcherResult.Success(0)
else MatcherResult.Failure
return if (possibleCursors.any { index >= it.selectionStart && index < it.selectionEnd }) {
val newPossibleCursors = possibleCursors.filter { index >= it.selectionStart && index < it.selectionEnd }
possibleCursors.clear()
possibleCursors.addAll(newPossibleCursors)
MatcherResult.Success(0)
} else {
MatcherResult.Failure
}
}
}

View File

@ -1728,6 +1728,20 @@ class NFATest {
)
}
@Test
fun `test cursor and visual belong to the same cursor`() {
doTest(
"${START}Lor${END}em Ipsum",
"\\%V.\\{-}\\%#.",
listOf(
mockCaret(0),
mockCaret(1),
mockCaret(2, Pair(0, 5)),
mockCaret(3),
)
)
}
companion object {
private fun assertFailure(
text: CharSequence,