1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-28 16:34:10 +02:00

Revert "Add readActions & EDT"

This reverts commit 45a2eadc58.
This commit is contained in:
Filipp Vakhitov 2024-01-31 20:09:08 +02:00
parent 5e0b1d0161
commit 0119912318
3 changed files with 52 additions and 58 deletions
src/main/java/com/maddyhome/idea/vim/newapi
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api

View File

@ -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) {

View File

@ -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
}
/**

View File

@ -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) {