diff --git a/src/main/java/com/maddyhome/idea/vim/newapi/IjVimCaret.kt b/src/main/java/com/maddyhome/idea/vim/newapi/IjVimCaret.kt index bbcc13c20..24453d81a 100644 --- a/src/main/java/com/maddyhome/idea/vim/newapi/IjVimCaret.kt +++ b/src/main/java/com/maddyhome/idea/vim/newapi/IjVimCaret.kt @@ -22,7 +22,6 @@ import com.maddyhome.idea.vim.api.VimCaret import com.maddyhome.idea.vim.api.VimCaretBase import com.maddyhome.idea.vim.api.VimEditor import com.maddyhome.idea.vim.api.VimVisualPosition -import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.common.EditorLine import com.maddyhome.idea.vim.common.LiveRange import com.maddyhome.idea.vim.common.Offset @@ -89,7 +88,7 @@ internal class IjVimCaret(val caret: Caret) : VimCaretBase() { override val editor: VimEditor get() = IjVimEditor(caret.editor) override val offset: Offset - get() = injector.application.runReadAction { caret.offset.offset } + get() = caret.offset.offset override var vimLastColumn: Int get() = caret.vimLastColumn set(value) { diff --git a/src/main/java/com/maddyhome/idea/vim/newapi/IjVimEditor.kt b/src/main/java/com/maddyhome/idea/vim/newapi/IjVimEditor.kt index 1711dca80..e3a9ee2d7 100644 --- a/src/main/java/com/maddyhome/idea/vim/newapi/IjVimEditor.kt +++ b/src/main/java/com/maddyhome/idea/vim/newapi/IjVimEditor.kt @@ -35,7 +35,6 @@ import com.maddyhome.idea.vim.api.VimScrollingModel import com.maddyhome.idea.vim.api.VimSelectionModel import com.maddyhome.idea.vim.api.VimVisualPosition import com.maddyhome.idea.vim.api.VirtualFile -import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.common.EditorLine import com.maddyhome.idea.vim.common.IndentConfig @@ -429,9 +428,7 @@ internal class IjVimEditor(editor: Editor) : MutableLinearEditor() { } override fun createLiveMarker(start: Offset, end: Offset): LiveRange { - return injector.application.runReadAction { - editor.document.createRangeMarker(start.point, end.point).vim - } + return editor.document.createRangeMarker(start.point, end.point).vim } /** diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimChangeGroupBase.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimChangeGroupBase.kt index 47682f12a..73e43fe5c 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimChangeGroupBase.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimChangeGroupBase.kt @@ -432,59 +432,57 @@ public abstract class VimChangeGroupBase : VimChangeGroup { * @param mode The mode - indicate insert or replace */ override fun initInsert(editor: VimEditor, context: ExecutionContext, mode: Mode) { - injector.application.invokeAndWait { - val state = getInstance(editor) - for (caret in editor.nativeCarets()) { - caret.vimInsertStart = editor.createLiveMarker(caret.offset, caret.offset) - injector.markService.setMark(caret, MARK_CHANGE_START, caret.offset.point) - } - val cmd = state.executingCommand - if (cmd != null && state.isDotRepeatInProgress) { - state.mode = mode - if (mode == Mode.REPLACE) { - editor.insertMode = false - } - if (cmd.flags.contains(CommandFlags.FLAG_NO_REPEAT_INSERT)) { - val commandState = getInstance(editor) - repeatInsert( - editor, - context, - 1, - false, - OperatorArguments(false, 1, commandState.mode), - ) - } else { - val commandState = getInstance(editor) - repeatInsert( - editor, - context, - cmd.count, - false, - OperatorArguments(false, cmd.count, commandState.mode), - ) - } - if (mode == Mode.REPLACE) { - editor.insertMode = true - } - state.mode = Mode.NORMAL() - } else { - lastInsert = cmd - strokes.clear() - repeatCharsCount = 0 - val myVimDocument = vimDocument - if (myVimDocument != null && vimDocumentListener != null) { - myVimDocument.removeChangeListener(vimDocumentListener!!) - } - vimDocument = editor.document - val myChangeListener = VimChangesListener() - vimDocumentListener = myChangeListener - vimDocument!!.addChangeListener(myChangeListener) - oldOffset = editor.currentCaret().offset.point - editor.insertMode = mode == Mode.INSERT - state.mode = mode - } - notifyListeners(editor) + val state = getInstance(editor) + for (caret in editor.nativeCarets()) { + caret.vimInsertStart = editor.createLiveMarker(caret.offset, caret.offset) + injector.markService.setMark(caret, MARK_CHANGE_START, caret.offset.point) } + val cmd = state.executingCommand + if (cmd != null && state.isDotRepeatInProgress) { + state.mode = mode + if (mode == Mode.REPLACE) { + editor.insertMode = false + } + if (cmd.flags.contains(CommandFlags.FLAG_NO_REPEAT_INSERT)) { + val commandState = getInstance(editor) + repeatInsert( + editor, + context, + 1, + false, + OperatorArguments(false, 1, commandState.mode), + ) + } else { + val commandState = getInstance(editor) + repeatInsert( + editor, + context, + cmd.count, + false, + OperatorArguments(false, cmd.count, commandState.mode), + ) + } + if (mode == Mode.REPLACE) { + editor.insertMode = true + } + state.mode = Mode.NORMAL() + } else { + lastInsert = cmd + strokes.clear() + repeatCharsCount = 0 + val myVimDocument = vimDocument + if (myVimDocument != null && vimDocumentListener != null) { + myVimDocument.removeChangeListener(vimDocumentListener!!) + } + vimDocument = editor.document + val myChangeListener = VimChangesListener() + vimDocumentListener = myChangeListener + vimDocument!!.addChangeListener(myChangeListener) + oldOffset = editor.currentCaret().offset.point + editor.insertMode = mode == Mode.INSERT + state.mode = mode + } + notifyListeners(editor) } override fun runEnterAction(editor: VimEditor, context: ExecutionContext) {