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

Fix an issue with disposed caret when moving up

There was an issue that when we enter visual block, move up, then try to switch to the visual line, we get a disposed caret issue.
This was caused by the fact that we get the list of carets, then process them one by one. However, as we update the first caret, the second gets disposed.
This commit is contained in:
Alex Plate 2023-08-01 16:17:39 +03:00
parent a703afbef9
commit a62cc3618c
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
2 changed files with 25 additions and 1 deletions
src/test/java/org/jetbrains/plugins/ideavim/action/motion/visual
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api

View File

@ -131,4 +131,28 @@ class VisualToggleLineModeActionTest : VimTestCase() {
typeText("V")
assertState(VimStateMachine.Mode.SELECT, VimStateMachine.SubMode.VISUAL_LINE)
}
@Test
fun `enter visual line from visual block with motion up`() {
doTest(
"<C-V>khV",
"""
Lorem Ipsum
Lorem ipsum dolor sit amet,
consectetur adipiscing elit
Sed in${c} orci mauris.
Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
"""
Lorem Ipsum
Lorem ipsum dolor sit amet,
${s}conse${c}ctetur adipiscing elit
Sed in orci mauris.
${se}Cras id tellus in ex imperdiet egestas.
""".trimIndent(),
VimStateMachine.Mode.VISUAL, VimStateMachine.SubMode.VISUAL_LINE
)
}
}

View File

@ -75,7 +75,7 @@ public abstract class VimVisualMotionGroupBase : VimVisualMotionGroup {
// Update visual subMode with new sub subMode
editor.subMode = subMode
for (caret in editor.carets()) {
editor.forEachCaret { caret ->
caret.vimUpdateEditorSelection()
}