mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-07 05:34:02 +02:00
Remove the use of write action in macros
This commit is contained in:
parent
a925676d64
commit
4ca25eed70
src/test/java/org/jetbrains/plugins/ideavim/action
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/macro
@ -55,6 +55,21 @@ class MacroActionTest : VimTestCase() {
|
||||
assertRegister('a', "ipp^[")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMacroWithIdeAction() {
|
||||
configureByText("""One
|
||||
|Two
|
||||
|Three
|
||||
|Four""".trimMargin())
|
||||
enterCommand("map j <Action>(EditorDown)")
|
||||
typeText(injector.parser.parseKeys("qa" + "j" + "q"))
|
||||
typeText(injector.parser.parseKeys("@a"))
|
||||
assertState("""One
|
||||
|Two
|
||||
|${c}Three
|
||||
|Four""".trimMargin())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRecordMacroWithDigraph() {
|
||||
typeTextInFile(injector.parser.parseKeys("qa" + "i" + "<C-K>OK<Esc>" + "q"), "")
|
||||
|
@ -33,10 +33,9 @@ class PlaybackRegisterAction : VimActionHandler.SingleExecution() {
|
||||
): Boolean {
|
||||
val argument = cmd.argument as? Argument.Character ?: return false
|
||||
val reg = argument.character
|
||||
val application = injector.application
|
||||
val res = arrayOf(false)
|
||||
when {
|
||||
reg == LAST_COMMAND_REGISTER || (reg == '@' && injector.macro.lastRegister == LAST_COMMAND_REGISTER) -> { // No write action
|
||||
reg == LAST_COMMAND_REGISTER || (reg == '@' && injector.macro.lastRegister == LAST_COMMAND_REGISTER) -> {
|
||||
try {
|
||||
var i = 0
|
||||
while (i < cmd.count) {
|
||||
@ -55,15 +54,11 @@ class PlaybackRegisterAction : VimActionHandler.SingleExecution() {
|
||||
}
|
||||
|
||||
reg == '@' -> {
|
||||
application.runWriteAction {
|
||||
res[0] = injector.macro.playbackLastRegister(editor, context, cmd.count)
|
||||
}
|
||||
res[0] = injector.macro.playbackLastRegister(editor, context, cmd.count)
|
||||
}
|
||||
|
||||
else -> {
|
||||
application.runWriteAction {
|
||||
res[0] = injector.macro.playbackRegister(editor, context, reg, cmd.count)
|
||||
}
|
||||
res[0] = injector.macro.playbackRegister(editor, context, reg, cmd.count)
|
||||
}
|
||||
}
|
||||
return res[0]
|
||||
|
Loading…
Reference in New Issue
Block a user