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

Add write action in several places

This commit is contained in:
Alex Plate 2025-02-21 19:32:47 +02:00
parent c9189ed7cb
commit 42d80f6866
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
2 changed files with 20 additions and 26 deletions
src/main/java/com/maddyhome/idea/vim/extension/exchange
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/put

View File

@ -8,7 +8,6 @@
package com.maddyhome.idea.vim.extension.exchange
import com.intellij.openapi.application.runWriteAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.LogicalPosition
import com.intellij.openapi.editor.colors.EditorColors
@ -111,12 +110,10 @@ internal class VimExchangeExtension : VimExtension {
private class VExchangeHandler : ExtensionHandler {
override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) {
runWriteAction {
val mode = editor.mode
// Leave visual mode to create selection marks
executeNormalWithoutMapping(injector.parser.parseKeys("<Esc>"), editor.ij)
Operator(true).apply(editor, context, mode.selectionType ?: SelectionType.CHARACTER_WISE)
}
val mode = editor.mode
// Leave visual mode to create selection marks
executeNormalWithoutMapping(injector.parser.parseKeys("<Esc>"), editor.ij)
Operator(true).apply(editor, context, mode.selectionType ?: SelectionType.CHARACTER_WISE)
}
}
@ -226,23 +223,22 @@ internal class VimExchangeExtension : VimExtension {
val unnRegText = getRegister(editor.vim, '"')
val startRegText = getRegister(editor.vim, '*')
val plusRegText = getRegister(editor.vim, '+')
runWriteAction {
// TODO handle:
// " Compare using =~ because "'==' != 0" returns 0
// let indent = s:get_setting('exchange_indent', 1) !~ 0 && a:x.type ==# 'V' && a:y.type ==# 'V'
pasteExchange(ex1, ex2)
if (!expand) {
pasteExchange(ex2, ex1)
}
// TODO: handle: if ident
if (!expand) {
fixCursor(ex1, ex2, reverse)
}
setRegister('z', zRegText)
setRegister('"', unnRegText)
setRegister('*', startRegText)
setRegister('+', plusRegText)
// TODO handle:
// " Compare using =~ because "'==' != 0" returns 0
// let indent = s:get_setting('exchange_indent', 1) !~ 0 && a:x.type ==# 'V' && a:y.type ==# 'V'
pasteExchange(ex1, ex2)
if (!expand) {
pasteExchange(ex2, ex1)
}
// TODO: handle: if ident
if (!expand) {
fixCursor(ex1, ex2, reverse)
}
setRegister('z', zRegText)
setRegister('"', unnRegText)
setRegister('*', startRegText)
setRegister('+', plusRegText)
}
private fun compareExchanges(x: Exchange, y: Exchange): ExchangeCompareResult {

View File

@ -580,9 +580,7 @@ abstract class VimPutBase : VimPut {
logger.debug("Perform put via plugin")
val myCarets = visualSelection?.caretsAndSelections?.keys?.sortedByDescending { it.getBufferPosition() }
?: editor.sortedNativeCarets().reversed()
injector.application.runWriteAction {
myCarets.forEach { caret -> putForCaret(editor, caret, data, additionalData, context, text) }
}
myCarets.forEach { caret -> putForCaret(editor, caret, data, additionalData, context, text) }
}
companion object {