Skip to content

Commit

Permalink
Fix(VIM-3695): Wrap getting a vimLeadSelectionOffset with a read action
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPl292 committed Nov 15, 2024
1 parent ed2fe3d commit 0e3cda8
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,14 @@ abstract class VimVisualMotionGroupBase : VimVisualMotionGroup {
val autodetectedSubMode = subMode ?: autodetectVisualSubmode(editor)
editor.mode = Mode.VISUAL(autodetectedSubMode)
// editor.vimStateMachine.setMode(VimStateMachine.Mode.VISUAL, autodetectedSubMode)
if (autodetectedSubMode == SelectionType.BLOCK_WISE) {
editor.primaryCaret().run { vimSelectionStart = vimLeadSelectionOffset }
} else {
editor.nativeCarets().forEach { it.vimSelectionStart = it.vimLeadSelectionOffset }

// vimLeadSelectionOffset requires read action
injector.application.runReadAction {
if (autodetectedSubMode == SelectionType.BLOCK_WISE) {
editor.primaryCaret().run { vimSelectionStart = vimLeadSelectionOffset }
} else {
editor.nativeCarets().forEach { it.vimSelectionStart = it.vimLeadSelectionOffset }
}
}
return true
}
Expand Down

0 comments on commit 0e3cda8

Please sign in to comment.