mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-25 18:34:08 +02:00
Add write action in several places
This commit is contained in:
parent
c9189ed7cb
commit
42d80f6866
src/main/java/com/maddyhome/idea/vim/extension/exchange
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/put
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
package com.maddyhome.idea.vim.extension.exchange
|
package com.maddyhome.idea.vim.extension.exchange
|
||||||
|
|
||||||
import com.intellij.openapi.application.runWriteAction
|
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import com.intellij.openapi.editor.LogicalPosition
|
import com.intellij.openapi.editor.LogicalPosition
|
||||||
import com.intellij.openapi.editor.colors.EditorColors
|
import com.intellij.openapi.editor.colors.EditorColors
|
||||||
@ -111,12 +110,10 @@ internal class VimExchangeExtension : VimExtension {
|
|||||||
|
|
||||||
private class VExchangeHandler : ExtensionHandler {
|
private class VExchangeHandler : ExtensionHandler {
|
||||||
override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) {
|
override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) {
|
||||||
runWriteAction {
|
val mode = editor.mode
|
||||||
val mode = editor.mode
|
// Leave visual mode to create selection marks
|
||||||
// Leave visual mode to create selection marks
|
executeNormalWithoutMapping(injector.parser.parseKeys("<Esc>"), editor.ij)
|
||||||
executeNormalWithoutMapping(injector.parser.parseKeys("<Esc>"), editor.ij)
|
Operator(true).apply(editor, context, mode.selectionType ?: SelectionType.CHARACTER_WISE)
|
||||||
Operator(true).apply(editor, context, mode.selectionType ?: SelectionType.CHARACTER_WISE)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,23 +223,22 @@ internal class VimExchangeExtension : VimExtension {
|
|||||||
val unnRegText = getRegister(editor.vim, '"')
|
val unnRegText = getRegister(editor.vim, '"')
|
||||||
val startRegText = getRegister(editor.vim, '*')
|
val startRegText = getRegister(editor.vim, '*')
|
||||||
val plusRegText = getRegister(editor.vim, '+')
|
val plusRegText = getRegister(editor.vim, '+')
|
||||||
runWriteAction {
|
|
||||||
// TODO handle:
|
// TODO handle:
|
||||||
// " Compare using =~ because "'==' != 0" returns 0
|
// " Compare using =~ because "'==' != 0" returns 0
|
||||||
// let indent = s:get_setting('exchange_indent', 1) !~ 0 && a:x.type ==# 'V' && a:y.type ==# 'V'
|
// let indent = s:get_setting('exchange_indent', 1) !~ 0 && a:x.type ==# 'V' && a:y.type ==# 'V'
|
||||||
pasteExchange(ex1, ex2)
|
pasteExchange(ex1, ex2)
|
||||||
if (!expand) {
|
if (!expand) {
|
||||||
pasteExchange(ex2, ex1)
|
pasteExchange(ex2, ex1)
|
||||||
}
|
|
||||||
// TODO: handle: if ident
|
|
||||||
if (!expand) {
|
|
||||||
fixCursor(ex1, ex2, reverse)
|
|
||||||
}
|
|
||||||
setRegister('z', zRegText)
|
|
||||||
setRegister('"', unnRegText)
|
|
||||||
setRegister('*', startRegText)
|
|
||||||
setRegister('+', plusRegText)
|
|
||||||
}
|
}
|
||||||
|
// 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 {
|
private fun compareExchanges(x: Exchange, y: Exchange): ExchangeCompareResult {
|
||||||
|
@ -580,9 +580,7 @@ abstract class VimPutBase : VimPut {
|
|||||||
logger.debug("Perform put via plugin")
|
logger.debug("Perform put via plugin")
|
||||||
val myCarets = visualSelection?.caretsAndSelections?.keys?.sortedByDescending { it.getBufferPosition() }
|
val myCarets = visualSelection?.caretsAndSelections?.keys?.sortedByDescending { it.getBufferPosition() }
|
||||||
?: editor.sortedNativeCarets().reversed()
|
?: 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 {
|
companion object {
|
||||||
|
Loading…
Reference in New Issue
Block a user