From d65a21919439d102500289d679597a705884c804 Mon Sep 17 00:00:00 2001 From: Alex Plate Date: Thu, 20 Feb 2025 19:13:39 +0200 Subject: [PATCH] Mark VimTestCase as deprecated --- .../jetbrains/plugins/ideavim/VimTestCase.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/testFixtures/kotlin/org/jetbrains/plugins/ideavim/VimTestCase.kt b/src/testFixtures/kotlin/org/jetbrains/plugins/ideavim/VimTestCase.kt index 8582052645..adfafe5ad5 100644 --- a/src/testFixtures/kotlin/org/jetbrains/plugins/ideavim/VimTestCase.kt +++ b/src/testFixtures/kotlin/org/jetbrains/plugins/ideavim/VimTestCase.kt @@ -113,9 +113,31 @@ import kotlin.test.assertTrue * To plugin writers: this class is internal, thus not allowed to be used by third-party plugins. * This is done as we have no mechanism to guarantee compatibility as we update this test case. * Feel free to copy this class into your plugin, or copy just needed functions. + * + * Deprecated: Use [VimNoWriteActionTestCase] + * Tests with [VimTestCase] are always started on the EDT with the write action. This is not only incorrect but also + * prevents an implementation of VIM-3376. + * + * If your test fails because of: + * Missing EDT: Wrap with `ApplicationManager.getInstance().invokeAndWait { }` + * Missing Write Action: Wrap with `ApplicationManager.getInstance().runWriteAction { }` + * Missing Read Action: Wrap with `ApplicationManager.getInstance().runReadAction { }` + * + * This wrapping may be needed right in the test if there is a platform call in the test itself. + * E.g. `fixture.editor.foldingModel.runBatchFoldingOperation`. + * + * However, there is a chance that the platform call happens deep in IdeaVim code. IdeaVim historically uses + * very broad EDT and write action scopes. This means we wrap with the write action almost at the top of the + * call stack. This is incorrect, the write action should be taken only in the place where it's necessary. + * So, try to properly introduce a write/read action wrapping in the IdeaVim code. If it's too complicated, + * wrap with write/read action the call in the test and mark it that the action wrapping should be done deeper in the code. */ @RunInEdt(writeIntent = true) @ApiStatus.Internal +@Deprecated( + "Use VimNoWriteActionTestCase instead", + replaceWith = ReplaceWith("VimNoWriteActionTestCase", "org.jetbrains.plugins.ideavim.VimNoWriteActionTestCase") +) abstract class VimTestCase : VimNoWriteActionTestCase() { object Checks { var caretShape: Boolean = true