mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-08 06:34:08 +02:00
Remove EDT and write action from the VimTestCase
This commit is contained in:
parent
24c0d31f14
commit
564ab7d75e
src
main/java/com/maddyhome/idea/vim
test/java/org/jetbrains/plugins/ideavim
action
CopyActionTest.ktMacroActionTest.ktMultipleCaretsTest.ktResetModeActionTest.kt
change
copy
IdeaPutNotificationsTest.ktPutTestAfterCursorActionTest.ktPutTextBeforeCursorActionTest.ktPutViaIdeaTest.ktPutVisualTextActionTest.ktPutVisualTextMoveCursorActionTest.kt
motion
mark
screen
select
updown
scroll
ex
extension
group
SearchGroupTest.kt
motion
MotionGroup_ScrollCaretIntoViewHorizontally_Test.ktMotionGroup_ScrollCaretIntoViewVertically_Test.kt
visual
helper
listener
option/overrides
BreakIndentOptionMapperTest.ktColorColumnOptionMapperTest.ktCursorLineOptionMapperTest.ktLineNumberOptionsMapperTest.ktListOptionMapperTest.ktScrollJumpOptionMapperTest.ktScrollOffOptionMapperTest.ktSideScrollOffOptionMapperTest.ktSideScrollOptionMapperTest.ktWrapOptionMapperTest.kt
regex
testFixtures/kotlin/org/jetbrains/plugins/ideavim
vim-engine/src/main/kotlin/com/maddyhome/idea/vim
@ -15,6 +15,7 @@ import com.intellij.openapi.editor.CaretVisualAttributes
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.ex.EditorEx
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||
import com.intellij.util.concurrency.annotations.RequiresEdt
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.globalOptions
|
||||
@ -88,7 +89,9 @@ private fun isBlockCursorOverride() = EditorSettingsExternalizable.getInstance()
|
||||
private fun Editor.updatePrimaryCaretVisualAttributes() {
|
||||
if (VimPlugin.isNotEnabled()) thisLogger().error("The caret attributes should not be updated if the IdeaVim is disabled")
|
||||
if (isIdeaVimDisabledHere) return
|
||||
caretModel.primaryCaret.visualAttributes = AttributesCache.getCaretVisualAttributes(this)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
caretModel.primaryCaret.visualAttributes = AttributesCache.getCaretVisualAttributes(this)
|
||||
}
|
||||
|
||||
// Make sure the caret is visible as soon as it's set. It might be invisible while blinking
|
||||
// NOTE: At the moment, this causes project leak in tests
|
||||
@ -163,12 +166,14 @@ class CaretVisualAttributesListener : IsReplaceCharListener, ModeChangeListener,
|
||||
updateCaretsVisual(editor)
|
||||
}
|
||||
|
||||
@RequiresEdt
|
||||
private fun updateCaretsVisual(editor: VimEditor) {
|
||||
val ijEditor = (editor as IjVimEditor).editor
|
||||
ijEditor.updateCaretsVisualAttributes()
|
||||
ijEditor.updateCaretsVisualPosition()
|
||||
}
|
||||
|
||||
@RequiresEdt
|
||||
fun updateAllEditorsCaretsVisual() {
|
||||
injector.editorGroup.getEditors().forEach { editor ->
|
||||
updateCaretsVisual(editor)
|
||||
|
@ -13,6 +13,8 @@ import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.LogicalPosition
|
||||
import com.intellij.openapi.editor.VisualPosition
|
||||
import com.intellij.util.concurrency.annotations.RequiresEdt
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
|
||||
/**
|
||||
* Move the caret to the given offset, handling inline inlays
|
||||
@ -35,6 +37,7 @@ import com.intellij.openapi.editor.VisualPosition
|
||||
* It is recommended to call this method even if the caret hasn't been moved. It will handle the situation where the
|
||||
* document has been changed to add an inlay at the caret position, and will move the caret appropriately.
|
||||
*/
|
||||
@RequiresEdt
|
||||
internal fun Caret.moveToInlayAwareOffset(offset: Int) {
|
||||
// If the target is inside a fold, call the standard moveToOffset to expand and move
|
||||
if (editor.foldingModel.isOffsetCollapsed(offset) || !editor.hasBlockOrUnderscoreCaret()) {
|
||||
@ -51,6 +54,7 @@ internal fun Caret.moveToInlayAwareLogicalPosition(pos: LogicalPosition) {
|
||||
moveToInlayAwareOffset(editor.logicalPositionToOffset(pos))
|
||||
}
|
||||
|
||||
@RequiresEdt
|
||||
private fun getVisualPositionForTextAtOffset(editor: Editor, offset: Int): VisualPosition {
|
||||
var logicalPosition = editor.offsetToLogicalPosition(offset)
|
||||
val e = if (editor is EditorWindow) {
|
||||
@ -81,15 +85,18 @@ internal fun Editor.amountOfInlaysBeforeVisualPosition(pos: VisualPosition): Int
|
||||
return this.inlayModel.getInlineElementsInRange(lineStartOffset, offset).size
|
||||
}
|
||||
|
||||
@RequiresEdt
|
||||
internal fun Editor.updateCaretsVisualPosition() {
|
||||
// Caret visual position depends on the current mode, especially with respect to inlays. E.g. if an inlay is
|
||||
// related to preceding text, the caret is placed between inlay and preceding text in insert mode (usually bar
|
||||
// caret) but after the inlay in normal mode (block caret).
|
||||
// By repositioning to the same offset, we will recalculate the expected visual position and put the caret in the
|
||||
// right location. Don't open a fold if the caret is inside
|
||||
this.vimForEachCaret {
|
||||
if (!this.foldingModel.isOffsetCollapsed(it.offset)) {
|
||||
it.moveToInlayAwareOffset(it.offset)
|
||||
injector.application.runReadAction {
|
||||
this.vimForEachCaret {
|
||||
if (!this.foldingModel.isOffsetCollapsed(it.offset)) {
|
||||
it.moveToInlayAwareOffset(it.offset)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,9 @@ internal object VimListenerManager {
|
||||
injector.listenersNotifier.myEditorListeners.add(caretVisualAttributesListener)
|
||||
injector.listenersNotifier.modeChangeListeners.add(caretVisualAttributesListener)
|
||||
injector.listenersNotifier.isReplaceCharListeners.add(caretVisualAttributesListener)
|
||||
caretVisualAttributesListener.updateAllEditorsCaretsVisual()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
caretVisualAttributesListener.updateAllEditorsCaretsVisual()
|
||||
}
|
||||
|
||||
val insertTimeRecorder = InsertTimeRecorder()
|
||||
injector.listenersNotifier.modeChangeListeners.add(insertTimeRecorder)
|
||||
@ -328,7 +330,9 @@ internal object VimListenerManager {
|
||||
injector.listenersNotifier.notifyEditorCreated(vimEditor)
|
||||
|
||||
Disposer.register(perEditorDisposable) {
|
||||
VimPlugin.getEditor().editorDeinit(editor)
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
VimPlugin.getEditor().editorDeinit(editor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
package org.jetbrains.plugins.ideavim.action
|
||||
|
||||
import com.intellij.idea.TestFor
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.KeyHandler
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
@ -185,7 +186,9 @@ class CopyActionTest : VimTestCase() {
|
||||
|
||||
""".trimIndent(),
|
||||
)
|
||||
kotlin.test.assertEquals(0, editor.caretModel.offset)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertEquals(0, editor.caretModel.offset)
|
||||
}
|
||||
}
|
||||
|
||||
// VIM-632 |CTRL-V| |v_y| |p|
|
||||
|
@ -264,7 +264,7 @@ class MacroActionTest : VimTestCase() {
|
||||
typeText("@q")
|
||||
}
|
||||
}
|
||||
assertEquals(ExceptionHandler.exceptionMessage, exception.cause!!.cause!!.message)
|
||||
assertEquals(ExceptionHandler.exceptionMessage, exception.cause!!.cause!!.cause!!.message)
|
||||
|
||||
assertTrue(KeyHandler.getInstance().keyStack.isEmpty())
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
package org.jetbrains.plugins.ideavim.action
|
||||
|
||||
import com.intellij.idea.TestFor
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.action.motion.search.SearchWholeWordForwardAction
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
@ -2184,15 +2185,17 @@ rtyfg${c}hzxc"""
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
injector.registerGroup.storeText(vimEditor, context, '*', "fgh")
|
||||
VimPlugin.getRegister()
|
||||
.storeText(
|
||||
IjVimEditor(editor),
|
||||
context,
|
||||
editor.vim.primaryCaret(),
|
||||
TextRange(16, 19),
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
VimPlugin.getRegister()
|
||||
.storeText(
|
||||
IjVimEditor(editor),
|
||||
context,
|
||||
editor.vim.primaryCaret(),
|
||||
TextRange(16, 19),
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("\"*P"))
|
||||
val after = "fg${c}hqfg${c}hwe asd zxc rty fg${c}hfgh vbn"
|
||||
assertState(after)
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.MappingMode
|
||||
@ -27,7 +28,9 @@ class ResetModeActionTest : VimTestCase() {
|
||||
val before = "Lorem Ipsum"
|
||||
val after = "Lorem Ipsum"
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -36,7 +39,9 @@ class ResetModeActionTest : VimTestCase() {
|
||||
val before = "Lorem Ipsum"
|
||||
val after = "Lorem Ipsum"
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -45,7 +50,9 @@ class ResetModeActionTest : VimTestCase() {
|
||||
val before = "A Disc${c}overy"
|
||||
val after = "A Dis${c}covery"
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -54,7 +61,9 @@ class ResetModeActionTest : VimTestCase() {
|
||||
val before = "${c}Lorem Ipsum"
|
||||
val after = "Lorem Ipsum"
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -63,7 +72,9 @@ class ResetModeActionTest : VimTestCase() {
|
||||
val before = "Lorem Ipsum"
|
||||
val after = "Lorem Ipsum"
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -72,7 +83,9 @@ class ResetModeActionTest : VimTestCase() {
|
||||
val before = "Lorem Ipsum"
|
||||
val after = "Lorem Ipsum"
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -81,7 +94,9 @@ class ResetModeActionTest : VimTestCase() {
|
||||
val before = "Lorem Ipsum"
|
||||
val after = "Lorem Ipsum"
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -90,7 +105,9 @@ class ResetModeActionTest : VimTestCase() {
|
||||
val before = "Lorem Ipsum"
|
||||
val after = "Ipsum"
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -99,7 +116,9 @@ class ResetModeActionTest : VimTestCase() {
|
||||
val before = "Lorem Ipsum"
|
||||
val after = "Ipsum"
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -108,7 +127,9 @@ class ResetModeActionTest : VimTestCase() {
|
||||
val before = "Lorem Ipsum"
|
||||
val after = "Ipsum"
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.CTRL_CODES)
|
||||
@ -118,7 +139,9 @@ class ResetModeActionTest : VimTestCase() {
|
||||
val before = "Lorem Ipsum"
|
||||
val after = "Ipsum"
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.MAPPING)
|
||||
@ -137,7 +160,9 @@ class ResetModeActionTest : VimTestCase() {
|
||||
val before = "Lorem Ipsum"
|
||||
val after = "Ipsum"
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -146,7 +171,9 @@ class ResetModeActionTest : VimTestCase() {
|
||||
val before = "Lorem Ipsum"
|
||||
val after = "Lnotherorem Ipsum"
|
||||
doTest(keys, before, after, Mode.INSERT)
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -155,6 +182,8 @@ class ResetModeActionTest : VimTestCase() {
|
||||
val before = "A ${c}Discovery"
|
||||
val after = "A "
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.selectionModel.hasSelection())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
package org.jetbrains.plugins.ideavim.action.change
|
||||
|
||||
import com.intellij.idea.TestFor
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.newapi.globalIjOptions
|
||||
import com.maddyhome.idea.vim.state.mode.Mode
|
||||
@ -31,7 +32,9 @@ class UndoActionTest : VimTestCase() {
|
||||
val after = before
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
val editor = fixture.editor
|
||||
kotlin.test.assertFalse(editor.caretModel.primaryCaret.hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(editor.caretModel.primaryCaret.hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -56,7 +59,9 @@ class UndoActionTest : VimTestCase() {
|
||||
Cras id tellus in ex imperdiet egestas.
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(hasSelection())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +85,9 @@ class UndoActionTest : VimTestCase() {
|
||||
Cras id tellus in ex imperdiet egestas.
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(hasSelection())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -105,7 +112,9 @@ class UndoActionTest : VimTestCase() {
|
||||
Cras id tellus in ex imperdiet egestas.
|
||||
""".trimIndent()
|
||||
doTest(keys, before, after, Mode.NORMAL())
|
||||
kotlin.test.assertFalse(hasSelection())
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(hasSelection())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.change.delete
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
@ -118,7 +119,9 @@ class DeleteCharacterLeftActionTest : VimTestCase() {
|
||||
// Scroll 70 characters to the left. First character on line should now be 71. sidescrolloff puts us at 76
|
||||
typeText("70zl")
|
||||
assertVisualPosition(0, 75)
|
||||
assertVisibleLineBounds(0, 70, 149)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
assertVisibleLineBounds(0, 70, 149)
|
||||
}
|
||||
|
||||
typeText("20X")
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
package org.jetbrains.plugins.ideavim.action.change.insert
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.HintRenderer
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.state.mode.Mode
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
@ -147,9 +148,11 @@ class VisualBlockInsertActionTest : VimTestCase() {
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent(),
|
||||
) {
|
||||
it.inlayModel.addInlineElement(before.indexOf("found"), HintRenderer("Hello"))
|
||||
it.inlayModel.addInlineElement(before.indexOf("l rocks"), HintRenderer("Hello"))
|
||||
it.inlayModel.addInlineElement(before.indexOf("ere it"), HintRenderer("Hello"))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
it.inlayModel.addInlineElement(before.indexOf("found"), HintRenderer("Hello"))
|
||||
it.inlayModel.addInlineElement(before.indexOf("l rocks"), HintRenderer("Hello"))
|
||||
it.inlayModel.addInlineElement(before.indexOf("ere it"), HintRenderer("Hello"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ package org.jetbrains.plugins.ideavim.action.copy
|
||||
import com.intellij.notification.ActionCenter
|
||||
import com.intellij.notification.EventLog
|
||||
import com.intellij.notification.Notification
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.group.NotificationService
|
||||
@ -34,14 +35,16 @@ class IdeaPutNotificationsTest : VimTestCase() {
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("p"))
|
||||
|
||||
val notification = notifications().last()
|
||||
@ -62,14 +65,16 @@ class IdeaPutNotificationsTest : VimTestCase() {
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("p"))
|
||||
|
||||
val notifications = notifications()
|
||||
@ -88,14 +93,16 @@ class IdeaPutNotificationsTest : VimTestCase() {
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("p"))
|
||||
|
||||
val notifications = EventLog.getLogModel(fixture.project).notifications
|
||||
|
@ -11,6 +11,7 @@ package org.jetbrains.plugins.ideavim.action.copy
|
||||
import com.intellij.codeInsight.editorActions.CopyPastePostProcessor
|
||||
import com.intellij.codeInsight.editorActions.CopyPastePreProcessor
|
||||
import com.intellij.codeInsight.editorActions.TextBlockTransferableData
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.CaretStateTransferableData
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.psi.PsiFile
|
||||
@ -88,14 +89,16 @@ class PutTestAfterCursorActionTest : VimTestCase() {
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -130,18 +133,22 @@ class PutTestAfterCursorActionTest : VimTestCase() {
|
||||
val editor = configureByText(before)
|
||||
// Add Guard to simulate Notebook behaviour. See (VIM-2577)
|
||||
val guardRange = before rangeOf "\nGUARD\n"
|
||||
editor.document.createGuardedBlock(guardRange.startOffset, guardRange.endOffset)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
editor.document.createGuardedBlock(guardRange.startOffset, guardRange.endOffset)
|
||||
}
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "I found it in a legendary land\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false,
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "I found it in a legendary land\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false,
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -168,14 +175,16 @@ class PutTestAfterCursorActionTest : VimTestCase() {
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("vep"))
|
||||
val after = """
|
||||
A Discovery
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.copy
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import com.maddyhome.idea.vim.state.mode.SelectionType
|
||||
@ -33,14 +34,16 @@ class PutTextBeforeCursorActionTest : VimTestCase() {
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "P"))
|
||||
typeText(injector.parser.parseKeys("V" + "P"))
|
||||
val after = """
|
||||
|
@ -10,6 +10,7 @@ package org.jetbrains.plugins.ideavim.action.copy
|
||||
|
||||
import com.intellij.codeInsight.editorActions.TextBlockTransferable
|
||||
import com.intellij.ide.CopyPasteManagerEx
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.ide.CopyPasteManager
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
@ -58,14 +59,16 @@ class PutViaIdeaTest : VimTestCase() {
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
typeText("ppp")
|
||||
val after = "Ilegendarylegendarylegendar${c}y found it in a legendary land"
|
||||
@ -85,14 +88,16 @@ class PutViaIdeaTest : VimTestCase() {
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary$randomUUID",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false,
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary$randomUUID",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
val sizeBefore = CopyPasteManager.getInstance().allContents.size
|
||||
typeText("ve", "p")
|
||||
@ -114,14 +119,16 @@ class PutViaIdeaTest : VimTestCase() {
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "\nLorem ipsum dolor sit amet,\n",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false,
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "\nLorem ipsum dolor sit amet,\n",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
typeText("p")
|
||||
val after = """
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.copy
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import com.maddyhome.idea.vim.state.mode.SelectionType
|
||||
@ -78,14 +79,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("ve" + "p"))
|
||||
val after = "legendar${c}y it in a legendary land"
|
||||
assertState(after)
|
||||
@ -101,14 +104,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("v2e" + "2p"))
|
||||
val after = "legendarylegendar${c}y in a legendary land"
|
||||
assertState(after)
|
||||
@ -124,14 +129,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("v$" + "2p"))
|
||||
val after = "legendarylegendar${c}y"
|
||||
assertState(after)
|
||||
@ -173,14 +180,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("vb" + "p"))
|
||||
val after = "I legendar${c}y it in a legendary land"
|
||||
assertState(after)
|
||||
@ -205,14 +214,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("ve" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -244,14 +255,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("ve" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -283,14 +296,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("ve" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -322,14 +337,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("v$" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -562,14 +579,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("ve" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -609,14 +628,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("ve" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -658,14 +679,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("ve" + "2p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -704,7 +727,9 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
configureByText(before)
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "|found|\n|l roc|\n|ere i|", SelectionType.BLOCK_WISE)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "|found|\n|l roc|\n|ere i|", SelectionType.BLOCK_WISE)
|
||||
}
|
||||
// registerService.storeText(editor.vim context,, editor.rangeOf("|found|", 2), SelectionType.BLOCK_WISE, false)
|
||||
typeText(injector.parser.parseKeys("ve" + "\"+p"))
|
||||
val after = """
|
||||
@ -744,7 +769,9 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
configureByText(before)
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "|found|\n|l roc|\n|ere i|", SelectionType.BLOCK_WISE)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "|found|\n|l roc|\n|ere i|", SelectionType.BLOCK_WISE)
|
||||
}
|
||||
// registerService.storeText(editor.vim context,, editor.rangeOf("|found|", 2), SelectionType.BLOCK_WISE, false)
|
||||
typeText(injector.parser.parseKeys("ve" + "\"+p"))
|
||||
val after = """
|
||||
@ -784,14 +811,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -821,14 +850,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "2p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -869,14 +900,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -914,7 +947,9 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
configureByText(before)
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
injector.registerGroup.storeText(vimEditor, context, '*', "Discovery", SelectionType.CHARACTER_WISE)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
injector.registerGroup.storeText(vimEditor, context, '*', "Discovery", SelectionType.CHARACTER_WISE)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "\"*p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -952,7 +987,9 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
configureByText(before)
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "Discovery", SelectionType.CHARACTER_WISE)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "Discovery", SelectionType.CHARACTER_WISE)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "\"+p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -990,7 +1027,9 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
configureByText(before)
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "Discovery", SelectionType.CHARACTER_WISE)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "Discovery", SelectionType.CHARACTER_WISE)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "\"+p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1028,7 +1067,9 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
configureByText(before)
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "Discovery", SelectionType.CHARACTER_WISE)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "Discovery", SelectionType.CHARACTER_WISE)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "\"+p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1061,14 +1102,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1098,14 +1141,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "2p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1146,14 +1191,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1191,7 +1238,9 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
configureByText(before)
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
injector.registerGroup.storeText(vimEditor, context, '*', "A Discovery\n", SelectionType.LINE_WISE)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
injector.registerGroup.storeText(vimEditor, context, '*', "A Discovery\n", SelectionType.LINE_WISE)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "\"*p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1229,7 +1278,9 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
configureByText(before)
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "A Discovery\n", SelectionType.LINE_WISE)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "A Discovery\n", SelectionType.LINE_WISE)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "\"+p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1267,7 +1318,9 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
configureByText(before)
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "A Discovery\n", SelectionType.LINE_WISE)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "A Discovery\n", SelectionType.LINE_WISE)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "\"+p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1305,7 +1358,9 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
configureByText(before)
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "A Discovery\n", SelectionType.LINE_WISE)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "A Discovery\n", SelectionType.LINE_WISE)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "\"+p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1343,14 +1398,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1409,14 +1466,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1481,14 +1540,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "2p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1549,7 +1610,9 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
configureByText(before)
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "|found|\n|l roc|\n|ere i|", SelectionType.BLOCK_WISE)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "|found|\n|l roc|\n|ere i|", SelectionType.BLOCK_WISE)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "\"+p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1612,7 +1675,9 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
configureByText(before)
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "|found|\n|l roc|\n|ere i|", SelectionType.BLOCK_WISE)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
injector.registerGroup.storeText(vimEditor, context, '+', "|found|\n|l roc|\n|ere i|", SelectionType.BLOCK_WISE)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "\"+p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1672,14 +1737,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-V>2e2j" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1709,14 +1776,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-V>3e2k" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1746,14 +1815,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-V>2e2j" + "2p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1783,14 +1854,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "Discovery",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-V>3j$" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1833,14 +1906,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-V>2e2j" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1872,14 +1947,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-V>2e2j" + "P"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1922,14 +1999,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-V>2e2j" + "2p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -1973,14 +2052,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-V>2e3j" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -2023,14 +2104,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
before rangeOf "A Discovery\n",
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-V>2j$" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -2069,14 +2152,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-V>2e2j" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -2116,14 +2201,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-V>2e3j" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -2163,14 +2250,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-V>2ej" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -2209,14 +2298,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-V>elj" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
@ -2257,14 +2348,16 @@ class PutVisualTextActionTest : VimTestCase() {
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
editor.rangeOf("|found|", 2),
|
||||
SelectionType.BLOCK_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-V>2j$" + "p"))
|
||||
val after = """
|
||||
A Discovery
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.copy
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
@ -34,14 +35,16 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 25),
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 25),
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("v2e" + "2gp"))
|
||||
val after = "legendarylegendary$c in a legendary land"
|
||||
assertState(after)
|
||||
@ -55,14 +58,16 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 25),
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 25),
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("v2e" + "gp"))
|
||||
val after = """
|
||||
|
||||
@ -80,14 +85,16 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 25),
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 25),
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "gp"))
|
||||
val after = "legendary\n$c"
|
||||
assertState(after)
|
||||
@ -116,14 +123,16 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(2, 11),
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(2, 11),
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "gp"))
|
||||
assertState(newFile)
|
||||
}
|
||||
@ -171,14 +180,16 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 25),
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 25),
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("v2e" + "gP"))
|
||||
val after = """
|
||||
|
||||
@ -196,14 +207,16 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 25),
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 25),
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("v2e" + "2gP"))
|
||||
val after = "legendarylegendary$c in a legendary land"
|
||||
assertState(after)
|
||||
@ -217,14 +230,16 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 25),
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 25),
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("v$" + "2gP"))
|
||||
val after = "legendarylegendar${c}y"
|
||||
assertState(after)
|
||||
@ -238,14 +253,16 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 25),
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 25),
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "gP"))
|
||||
val after = "legendary\n$c"
|
||||
assertState(after)
|
||||
@ -385,14 +402,16 @@ class PutVisualTextMoveCursorActionTest : VimTestCase() {
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 19),
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
registerService.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
TextRange(16, 19),
|
||||
SelectionType.LINE_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("<C-v>" + "h" + "gp"))
|
||||
val after = """
|
||||
q
|
||||
|
@ -10,6 +10,7 @@ package org.jetbrains.plugins.ideavim.action.motion.mark
|
||||
|
||||
import com.intellij.ide.bookmark.BookmarksManager
|
||||
import com.intellij.ide.bookmark.LineBookmark
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.group.createLineBookmark
|
||||
@ -101,7 +102,9 @@ class MotionMarkActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
configureByText(text)
|
||||
fixture.project.createLineBookmark(fixture.editor, 2, 'A')
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
}
|
||||
val vimMarks = injector.markService.getAllGlobalMarks()
|
||||
kotlin.test.assertEquals(1, vimMarks.size)
|
||||
kotlin.test.assertEquals('A', vimMarks.first().key)
|
||||
@ -123,7 +126,9 @@ class MotionMarkActionTest : VimTestCase() {
|
||||
|
||||
BookmarksManager.getInstance(fixture.project)?.remove(bookmark!!)
|
||||
fixture.project.createLineBookmark(fixture.editor, 4, 'A')
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
}
|
||||
val vimMarks = injector.markService.getAllGlobalMarks()
|
||||
kotlin.test.assertEquals(1, vimMarks.size)
|
||||
val mark = vimMarks.first()
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.motion.screen
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.api.getOffset
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
@ -178,7 +179,9 @@ class MotionFirstScreenLineActionTest : VimTestCase() {
|
||||
fun `test move caret to first line of screen with inlays`() {
|
||||
// We're not scrolling, so inlays don't affect anything. Just place the caret on the first visible line
|
||||
configureByLines(50, " I found it in a legendary land")
|
||||
addBlockInlay(fixture.editor.vim.getOffset(5, 5), true, 10)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
addBlockInlay(fixture.editor.vim.getOffset(5, 5), true, 10)
|
||||
}
|
||||
setPositionAndScroll(0, 20, 10)
|
||||
typeText("H")
|
||||
assertPosition(0, 4)
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.motion.select
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.maddyhome.idea.vim.state.mode.Mode
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
@ -341,9 +342,11 @@ class SelectEscapeActionTest : VimTestCase() {
|
||||
""".trimIndent(),
|
||||
Mode.NORMAL(),
|
||||
)
|
||||
kotlin.test.assertFalse(fixture.editor.caretModel.allCarets.any(Caret::hasSelection))
|
||||
kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount)
|
||||
assertCaretsVisualAttributes()
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.caretModel.allCarets.any(Caret::hasSelection))
|
||||
kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount)
|
||||
assertCaretsVisualAttributes()
|
||||
}
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.SELECT_MODE)
|
||||
@ -369,9 +372,11 @@ class SelectEscapeActionTest : VimTestCase() {
|
||||
""".trimIndent(),
|
||||
Mode.NORMAL(),
|
||||
)
|
||||
kotlin.test.assertFalse(fixture.editor.caretModel.allCarets.any(Caret::hasSelection))
|
||||
kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount)
|
||||
assertCaretsVisualAttributes()
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.caretModel.allCarets.any(Caret::hasSelection))
|
||||
kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount)
|
||||
assertCaretsVisualAttributes()
|
||||
}
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.SELECT_MODE)
|
||||
@ -397,9 +402,11 @@ class SelectEscapeActionTest : VimTestCase() {
|
||||
""".trimIndent(),
|
||||
Mode.NORMAL(),
|
||||
)
|
||||
kotlin.test.assertFalse(fixture.editor.caretModel.allCarets.any(Caret::hasSelection))
|
||||
kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount)
|
||||
assertCaretsVisualAttributes()
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.caretModel.allCarets.any(Caret::hasSelection))
|
||||
kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount)
|
||||
assertCaretsVisualAttributes()
|
||||
}
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.SELECT_MODE)
|
||||
@ -425,8 +432,10 @@ class SelectEscapeActionTest : VimTestCase() {
|
||||
""".trimIndent(),
|
||||
Mode.NORMAL(),
|
||||
)
|
||||
kotlin.test.assertFalse(fixture.editor.caretModel.allCarets.any(Caret::hasSelection))
|
||||
kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount)
|
||||
assertCaretsVisualAttributes()
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
kotlin.test.assertFalse(fixture.editor.caretModel.allCarets.any(Caret::hasSelection))
|
||||
kotlin.test.assertEquals(1, fixture.editor.caretModel.caretCount)
|
||||
assertCaretsVisualAttributes()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
package org.jetbrains.plugins.ideavim.action.motion.updown
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.HintRenderer
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.state.mode.Mode
|
||||
import com.maddyhome.idea.vim.state.mode.SelectionType
|
||||
@ -219,7 +220,9 @@ class MotionDownActionTest : VimTestCase() {
|
||||
all rocks and la${c}vender and tufted grass,
|
||||
""".trimIndent()
|
||||
configureByText(before)
|
||||
fixture.editor.inlayModel.addInlineElement(2, HintRenderer("Hello"))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.inlayModel.addInlineElement(2, HintRenderer("Hello"))
|
||||
}
|
||||
typeText(keys)
|
||||
assertState(after)
|
||||
}
|
||||
@ -236,7 +239,9 @@ class MotionDownActionTest : VimTestCase() {
|
||||
all rocks and la${c}vender and tufted grass,
|
||||
""".trimIndent()
|
||||
configureByText(before)
|
||||
fixture.editor.inlayModel.addInlineElement(before.indexOf("rocks"), HintRenderer("Hello"))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.inlayModel.addInlineElement(before.indexOf("rocks"), HintRenderer("Hello"))
|
||||
}
|
||||
typeText(keys)
|
||||
assertState(after)
|
||||
}
|
||||
@ -253,8 +258,10 @@ class MotionDownActionTest : VimTestCase() {
|
||||
all rocks and la${c}vender and tufted grass,
|
||||
""".trimIndent()
|
||||
configureByText(before)
|
||||
fixture.editor.inlayModel.addInlineElement(before.indexOf("rocks"), HintRenderer("Hello"))
|
||||
fixture.editor.inlayModel.addInlineElement(before.indexOf("found"), HintRenderer("Hello"))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.inlayModel.addInlineElement(before.indexOf("rocks"), HintRenderer("Hello"))
|
||||
fixture.editor.inlayModel.addInlineElement(before.indexOf("found"), HintRenderer("Hello"))
|
||||
}
|
||||
typeText(keys)
|
||||
assertState(after)
|
||||
}
|
||||
@ -271,7 +278,9 @@ class MotionDownActionTest : VimTestCase() {
|
||||
all rocks and lavende${c}r
|
||||
""".trimIndent()
|
||||
configureByText(before)
|
||||
fixture.editor.inlayModel.addInlineElement(before.indexOf("found"), HintRenderer("Hello"))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.inlayModel.addInlineElement(before.indexOf("found"), HintRenderer("Hello"))
|
||||
}
|
||||
typeText(keys)
|
||||
assertState(after)
|
||||
}
|
||||
@ -288,7 +297,9 @@ class MotionDownActionTest : VimTestCase() {
|
||||
all rocks and lavender
|
||||
""".trimIndent()
|
||||
configureByText(before)
|
||||
fixture.editor.inlayModel.addInlineElement(before.indexOf("found"), HintRenderer("Hello"))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.inlayModel.addInlineElement(before.indexOf("found"), HintRenderer("Hello"))
|
||||
}
|
||||
typeText(keys)
|
||||
assertState(after)
|
||||
}
|
||||
@ -321,7 +332,9 @@ class MotionDownActionTest : VimTestCase() {
|
||||
all rocks and lavende${c}r
|
||||
""".trimIndent()
|
||||
configureByText(before)
|
||||
fixture.editor.inlayModel.addInlineElement(before.indexOf("rocks"), HintRenderer("Hello"))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.inlayModel.addInlineElement(before.indexOf("rocks"), HintRenderer("Hello"))
|
||||
}
|
||||
typeText(keys)
|
||||
assertState(after)
|
||||
}
|
||||
@ -341,7 +354,9 @@ class MotionDownActionTest : VimTestCase() {
|
||||
""".trimIndent()
|
||||
configureByText(before)
|
||||
val inlayOffset = fixture.editor.document.getLineEndOffset(1)
|
||||
fixture.editor.inlayModel.addInlineElement(inlayOffset, HintRenderer("Hello"))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.inlayModel.addInlineElement(inlayOffset, HintRenderer("Hello"))
|
||||
}
|
||||
typeText(keys)
|
||||
assertState(after)
|
||||
}
|
||||
@ -358,7 +373,9 @@ class MotionDownActionTest : VimTestCase() {
|
||||
all rocks and lavender
|
||||
""".trimIndent()
|
||||
configureByText(before)
|
||||
fixture.editor.inlayModel.addInlineElement(before.indexOf("rocks"), HintRenderer("Hello"))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.inlayModel.addInlineElement(before.indexOf("rocks"), HintRenderer("Hello"))
|
||||
}
|
||||
typeText(keys)
|
||||
assertState(after)
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.motion.updown
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
@ -62,7 +63,9 @@ class MotionUpActionTest : VimTestCase() {
|
||||
) {
|
||||
// Simulate the caret being moved without IdeaVim knowing and therefore without vimLastColumn being updated
|
||||
// This offset is effectively "lave${c}nder"
|
||||
it.caretModel.primaryCaret.moveToOffset(49)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
it.caretModel.primaryCaret.moveToOffset(49)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.scroll
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.Inlay
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import org.jetbrains.plugins.ideavim.VimBehaviorDiffers
|
||||
@ -68,13 +69,15 @@ class ScrollFirstScreenColumnActionTest : VimTestCase() {
|
||||
configureByColumns(200)
|
||||
val inlay = addInlay(99, false, 5)
|
||||
typeText("100|", "zs")
|
||||
val visibleArea = fixture.editor.scrollingModel.visibleArea
|
||||
val textWidth = visibleArea.width - inlay.widthInPixels
|
||||
val availableColumns = (textWidth / EditorHelper.getPlainSpaceWidthFloat(fixture.editor)).roundToInt()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
val visibleArea = fixture.editor.scrollingModel.visibleArea
|
||||
val textWidth = visibleArea.width - inlay.widthInPixels
|
||||
val availableColumns = (textWidth / EditorHelper.getPlainSpaceWidthFloat(fixture.editor)).roundToInt()
|
||||
|
||||
// The first visible text column will be 99, with the inlay positioned to the left of it
|
||||
assertVisibleLineBounds(0, 99, 99 + availableColumns - 1)
|
||||
assertEquals(visibleArea.x, inlay.bounds!!.x)
|
||||
// The first visible text column will be 99, with the inlay positioned to the left of it
|
||||
assertVisibleLineBounds(0, 99, 99 + availableColumns - 1)
|
||||
assertEquals(visibleArea.x, inlay.bounds!!.x)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -92,8 +95,10 @@ class ScrollFirstScreenColumnActionTest : VimTestCase() {
|
||||
configureByColumns(200)
|
||||
val inlay = addInlay(100, false, 5)
|
||||
typeText("100|", "zs")
|
||||
val availableColumns = getAvailableColumns(inlay)
|
||||
assertVisibleLineBounds(0, 99, 99 + availableColumns - 1)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
val availableColumns = getAvailableColumns(inlay)
|
||||
assertVisibleLineBounds(0, 99, 99 + availableColumns - 1)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -102,8 +107,10 @@ class ScrollFirstScreenColumnActionTest : VimTestCase() {
|
||||
configureByColumns(200)
|
||||
val inlay = addInlay(100, true, 5)
|
||||
typeText("100|", "zs")
|
||||
val availableColumns = getAvailableColumns(inlay)
|
||||
assertVisibleLineBounds(0, 99, 99 + availableColumns - 1)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
val availableColumns = getAvailableColumns(inlay)
|
||||
assertVisibleLineBounds(0, 99, 99 + availableColumns - 1)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAvailableColumns(inlay: Inlay<*>): Int {
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.action.scroll
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.Inlay
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
@ -103,17 +104,19 @@ class ScrollLastScreenColumnActionTest : VimTestCase() {
|
||||
configureByColumns(200)
|
||||
val inlay = addInlay(100, true, 5)
|
||||
typeText("100|", "ze")
|
||||
val visibleArea = fixture.editor.scrollingModel.visibleArea
|
||||
val textWidth = visibleArea.width - inlay.widthInPixels
|
||||
val availableColumns = (textWidth / EditorHelper.getPlainSpaceWidthFloat(fixture.editor)).roundToInt()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
val visibleArea = fixture.editor.scrollingModel.visibleArea
|
||||
val textWidth = visibleArea.width - inlay.widthInPixels
|
||||
val availableColumns = (textWidth / EditorHelper.getPlainSpaceWidthFloat(fixture.editor)).roundToInt()
|
||||
|
||||
// The last visible text column will be 99, but it will be positioned before the inlay
|
||||
assertVisibleLineBounds(0, 99 - availableColumns + 1, 99)
|
||||
// The last visible text column will be 99, but it will be positioned before the inlay
|
||||
assertVisibleLineBounds(0, 99 - availableColumns + 1, 99)
|
||||
|
||||
// We have to assert the location of the inlay
|
||||
val inlayX = fixture.editor.visualPositionToPoint2D(inlay.visualPosition).x.roundToInt()
|
||||
assertEquals(visibleArea.x + textWidth, inlayX)
|
||||
assertEquals(visibleArea.x + visibleArea.width, inlayX + inlay.widthInPixels)
|
||||
// We have to assert the location of the inlay
|
||||
val inlayX = fixture.editor.visualPositionToPoint2D(inlay.visualPosition).x.roundToInt()
|
||||
assertEquals(visibleArea.x + textWidth, inlayX)
|
||||
assertEquals(visibleArea.x + visibleArea.width, inlayX + inlay.widthInPixels)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -127,7 +130,11 @@ class ScrollLastScreenColumnActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
private fun getAvailableColumns(inlay: Inlay<*>): Int {
|
||||
val textWidth = fixture.editor.scrollingModel.visibleArea.width - inlay.widthInPixels
|
||||
return (textWidth / EditorHelper.getPlainSpaceWidthFloat(fixture.editor)).roundToInt()
|
||||
var res: Int? = null
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
val textWidth = fixture.editor.scrollingModel.visibleArea.width - inlay.widthInPixels
|
||||
res = (textWidth / EditorHelper.getPlainSpaceWidthFloat(fixture.editor)).roundToInt()
|
||||
}
|
||||
return res!!
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
package org.jetbrains.plugins.ideavim.ex
|
||||
|
||||
import com.intellij.idea.TestFor
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
@ -96,7 +97,11 @@ class ExEntryTest : VimTestCase() {
|
||||
assertIsDeactivated()
|
||||
|
||||
deactivateExEntry()
|
||||
VimPlugin.getOptionGroup().resetAllOptions(fixture.editor.vim)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
VimPlugin.getOptionGroup().resetAllOptions(fixture.editor.vim)
|
||||
}
|
||||
}
|
||||
|
||||
assertFalse(options().incsearch)
|
||||
typeExInput(":set incsearch<C-J>")
|
||||
@ -104,7 +109,9 @@ class ExEntryTest : VimTestCase() {
|
||||
assertIsDeactivated()
|
||||
|
||||
deactivateExEntry()
|
||||
VimPlugin.getOptionGroup().resetAllOptions(fixture.editor.vim)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
VimPlugin.getOptionGroup().resetAllOptions(fixture.editor.vim)
|
||||
}
|
||||
|
||||
assertFalse(options().incsearch)
|
||||
typeExInput(":set incsearch<C-M>")
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.ex
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
@ -131,8 +132,10 @@ class MultipleCaretsTest : VimTestCase() {
|
||||
val editor = configureByText(before)
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 19), SelectionType.CHARACTER_WISE, false)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 19), SelectionType.CHARACTER_WISE, false)
|
||||
}
|
||||
typeText(commandToKeys("pu"))
|
||||
val after = """
|
||||
qwe
|
||||
@ -167,8 +170,10 @@ class MultipleCaretsTest : VimTestCase() {
|
||||
val editor = configureByText(before)
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 19), SelectionType.CHARACTER_WISE, false)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 19), SelectionType.CHARACTER_WISE, false)
|
||||
}
|
||||
typeText(commandToKeys("pu"))
|
||||
val after = """
|
||||
qwe
|
||||
@ -204,8 +209,10 @@ class MultipleCaretsTest : VimTestCase() {
|
||||
val editor = configureByText(before)
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 19), SelectionType.CHARACTER_WISE, false)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 19), SelectionType.CHARACTER_WISE, false)
|
||||
}
|
||||
typeText(commandToKeys("4pu"))
|
||||
val after = """
|
||||
qwe
|
||||
@ -241,8 +248,10 @@ class MultipleCaretsTest : VimTestCase() {
|
||||
val editor = configureByText(before)
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 19), SelectionType.CHARACTER_WISE, false)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), TextRange(16, 19), SelectionType.CHARACTER_WISE, false)
|
||||
}
|
||||
typeText(commandToKeys("4pu"))
|
||||
val after = """
|
||||
qwe
|
||||
@ -264,8 +273,10 @@ class MultipleCaretsTest : VimTestCase() {
|
||||
val editor = configureByText(before)
|
||||
val vimEditor = editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, editor.vim.primaryCaret(), TextRange(16, 19), SelectionType.CHARACTER_WISE, false)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, editor.vim.primaryCaret(), TextRange(16, 19), SelectionType.CHARACTER_WISE, false)
|
||||
}
|
||||
|
||||
typeText("vj")
|
||||
typeText(commandToKeys("pu"))
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.ex.implementation.commands
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
@ -20,8 +21,10 @@ class BufferCloseCommandTest : VimTestCase() {
|
||||
val psiFile1 = fixture.configureByText("A_Discovery1", "Lorem ipsum dolor sit amet,")
|
||||
val psiFile2 = fixture.configureByText("A_Discovery2", "consectetur adipiscing elit")
|
||||
|
||||
fileManager.openFile(psiFile1.virtualFile, false)
|
||||
fileManager.openFile(psiFile2.virtualFile, true)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fileManager.openFile(psiFile1.virtualFile, false)
|
||||
fileManager.openFile(psiFile2.virtualFile, true)
|
||||
}
|
||||
assertPluginError(false)
|
||||
|
||||
typeText(commandToKeys("bd"))
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.ex.implementation.commands
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
@ -22,7 +23,9 @@ class ExitCommandTest : VimTestCase() {
|
||||
}
|
||||
@Suppress("IdeaVimAssertState")
|
||||
val psiFile = fixture.configureByText("A_Discovery", "Lorem ipsum dolor sit amet,")
|
||||
fileManager.openFile(psiFile.virtualFile, false)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fileManager.openFile(psiFile.virtualFile, false)
|
||||
}
|
||||
kotlin.test.assertNotNull<Any>(fileManager.currentFile)
|
||||
|
||||
typeText(commandToKeys("qa"))
|
||||
@ -36,7 +39,9 @@ class ExitCommandTest : VimTestCase() {
|
||||
}
|
||||
@Suppress("IdeaVimAssertState")
|
||||
val psiFile = fixture.configureByText("A_Discovery", "Lorem ipsum dolor sit amet,")
|
||||
fileManager.openFile(psiFile.virtualFile, false)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fileManager.openFile(psiFile.virtualFile, false)
|
||||
}
|
||||
kotlin.test.assertNotNull<Any>(fileManager.currentFile)
|
||||
|
||||
typeText(commandToKeys("qall"))
|
||||
@ -51,8 +56,10 @@ class ExitCommandTest : VimTestCase() {
|
||||
}
|
||||
val psiFile1 = fixture.configureByText("A_Discovery1", "Lorem ipsum dolor sit amet,")
|
||||
val psiFile2 = fixture.configureByText("A_Discovery2", "consectetur adipiscing elit")
|
||||
fileManager.openFile(psiFile1.virtualFile, false)
|
||||
fileManager.openFile(psiFile2.virtualFile, false)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fileManager.openFile(psiFile1.virtualFile, false)
|
||||
fileManager.openFile(psiFile2.virtualFile, false)
|
||||
}
|
||||
kotlin.test.assertNotNull<Any>(fileManager.currentFile)
|
||||
|
||||
typeText(commandToKeys("qa"))
|
||||
|
@ -9,6 +9,7 @@
|
||||
package org.jetbrains.plugins.ideavim.ex.implementation.commands
|
||||
|
||||
import com.intellij.idea.TestFor
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.api.options
|
||||
@ -316,7 +317,9 @@ class GlobalCommandTest : VimTestCase() {
|
||||
fun `test print multiple matching line if no command with number option`() {
|
||||
configureByText(initialText)
|
||||
val editor = fixture.editor.vim
|
||||
injector.options(editor).number = true
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
injector.options(editor).number = true
|
||||
}
|
||||
typeText(commandToKeys(":g/it"))
|
||||
assertExOutput(
|
||||
"""
|
||||
@ -325,7 +328,9 @@ class GlobalCommandTest : VimTestCase() {
|
||||
|5 where it was settled on some sodden sand
|
||||
""".trimMargin()
|
||||
)
|
||||
injector.options(editor).number = false
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
injector.options(editor).number = false
|
||||
}
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||
@ -348,14 +353,18 @@ class GlobalCommandTest : VimTestCase() {
|
||||
fun `test print matching lines if no command and no trailing separator with number option`() {
|
||||
configureByText(initialText)
|
||||
val editor = fixture.editor.vim
|
||||
injector.options(editor).number = true
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
injector.options(editor).number = true
|
||||
}
|
||||
typeText(commandToKeys(":g/found/"))
|
||||
assertExOutput(
|
||||
"""
|
||||
g/found/
|
||||
3 I found it in a legendary land""".trimIndent()
|
||||
)
|
||||
injector.options(editor).number = false
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
injector.options(editor).number = false
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1049,7 +1049,7 @@ class MapCommandTest : VimTestCase() {
|
||||
typeText("k")
|
||||
}
|
||||
}
|
||||
assertEquals(ExceptionHandler.exceptionMessage, exception.cause!!.cause!!.message)
|
||||
assertEquals(ExceptionHandler.exceptionMessage, exception.cause!!.cause!!.cause!!.message)
|
||||
|
||||
assertTrue(KeyHandler.getInstance().keyStack.isEmpty())
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.ex.implementation.commands
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.api.options
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
@ -78,7 +79,9 @@ class PrintCommandTest : VimTestCase() {
|
||||
fun `test moves caret to start of last line of range skipping whitespace with number option`() {
|
||||
configureByText(initialText)
|
||||
val editor = fixture.editor.vim
|
||||
injector.options(editor).number = true
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
injector.options(editor).number = true
|
||||
}
|
||||
typeText(commandToKeys("2,5p"))
|
||||
assertExOutput(
|
||||
"""
|
||||
@ -88,7 +91,9 @@ class PrintCommandTest : VimTestCase() {
|
||||
|5 Sed in orci mauris.
|
||||
""".trimMargin(),
|
||||
)
|
||||
injector.options(editor).number = false
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
injector.options(editor).number = false
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -10,6 +10,7 @@ package org.jetbrains.plugins.ideavim.extension
|
||||
|
||||
import com.intellij.ide.plugins.PluginManagerCore
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.invokeLater
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
@ -182,11 +183,15 @@ class OpMappingTest : VimTestCase() {
|
||||
fun `test delayed action`() {
|
||||
configureByText("${c}I found it in a legendary land")
|
||||
typeText("R")
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
}
|
||||
assertState("I fou${c}nd it in a legendary land")
|
||||
|
||||
typeText("dR")
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
}
|
||||
assertState("I fou$c in a legendary land")
|
||||
}
|
||||
|
||||
@ -197,11 +202,15 @@ class OpMappingTest : VimTestCase() {
|
||||
fun `test delayed incorrect action`() {
|
||||
configureByText("${c}I found it in a legendary land")
|
||||
typeText("E")
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
}
|
||||
assertState("I fou${c}nd it in a legendary land")
|
||||
|
||||
typeText("dE")
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||
}
|
||||
assertState("I found it$c in a legendary land")
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.extension.multiplecursors
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import com.maddyhome.idea.vim.state.mode.Mode
|
||||
@ -189,7 +190,9 @@ class VimMultipleCursorsExtensionTest : VimTestCase() {
|
||||
|dfkjsg
|
||||
""".trimMargin()
|
||||
val editor = configureByText(before)
|
||||
editor.vim.mode = Mode.VISUAL(SelectionType.CHARACTER_WISE)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
editor.vim.mode = Mode.VISUAL(SelectionType.CHARACTER_WISE)
|
||||
}
|
||||
|
||||
typeText(injector.parser.parseKeys("<A-p>"))
|
||||
|
||||
@ -272,7 +275,9 @@ class VimMultipleCursorsExtensionTest : VimTestCase() {
|
||||
|dfkjsg
|
||||
""".trimMargin()
|
||||
val editor = configureByText(before)
|
||||
editor.vim.mode = Mode.VISUAL(SelectionType.CHARACTER_WISE)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
editor.vim.mode = Mode.VISUAL(SelectionType.CHARACTER_WISE)
|
||||
}
|
||||
|
||||
typeText(injector.parser.parseKeys("<A-x>"))
|
||||
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
|
||||
@ -362,7 +367,9 @@ fun getCellType(${s}pos$se: VisualPosition): CellType {
|
||||
fun `test ignores regex in search pattern`() {
|
||||
val before = "test ${s}t.*st${c}$se toast tallest t.*st"
|
||||
val editor = configureByText(before)
|
||||
editor.vim.mode = Mode.VISUAL(SelectionType.CHARACTER_WISE)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
editor.vim.mode = Mode.VISUAL(SelectionType.CHARACTER_WISE)
|
||||
}
|
||||
|
||||
typeText(injector.parser.parseKeys("<A-n><A-n>"))
|
||||
val after = "test ${s}t.*st$se toast tallest ${s}t.*st$se"
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.extension.replacewithregister
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
@ -50,8 +51,10 @@ class ReplaceWithRegisterTest : VimTestCase() {
|
||||
configureByText(text)
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), text rangeOf "one", SelectionType.CHARACTER_WISE, false)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), text rangeOf "one", SelectionType.CHARACTER_WISE, false)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("griw"))
|
||||
assertState("one on${c}e three")
|
||||
val registerService = injector.registerGroup
|
||||
@ -177,8 +180,10 @@ class ReplaceWithRegisterTest : VimTestCase() {
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), text rangeOf "one", SelectionType.CHARACTER_WISE, false)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), text rangeOf "one", SelectionType.CHARACTER_WISE, false)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("3griw"))
|
||||
assertState("one on${c}e four")
|
||||
assertEquals("one", registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text)
|
||||
@ -193,8 +198,10 @@ class ReplaceWithRegisterTest : VimTestCase() {
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), text rangeOf "one", SelectionType.CHARACTER_WISE, false)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), text rangeOf "one", SelectionType.CHARACTER_WISE, false)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("griw"))
|
||||
assertState("one two one four")
|
||||
assertEquals("one", registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text)
|
||||
@ -208,8 +215,10 @@ class ReplaceWithRegisterTest : VimTestCase() {
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), text rangeOf "one", SelectionType.CHARACTER_WISE, false)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
VimPlugin.getRegister()
|
||||
.storeText(vimEditor, context, vimEditor.primaryCaret(), text rangeOf "one", SelectionType.CHARACTER_WISE, false)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("griw" + "w" + "."))
|
||||
assertState("one one on${c}e four")
|
||||
assertEquals("one", registerService.getRegister(vimEditor, context, registerService.lastRegisterChar)?.text)
|
||||
@ -260,8 +269,8 @@ class ReplaceWithRegisterTest : VimTestCase() {
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
VimPlugin.getRegister()
|
||||
.storeText(
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
VimPlugin.getRegister().storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
@ -269,6 +278,7 @@ class ReplaceWithRegisterTest : VimTestCase() {
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("grr"))
|
||||
assertState(
|
||||
"""
|
||||
@ -436,15 +446,17 @@ class ReplaceWithRegisterTest : VimTestCase() {
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
val registerService = injector.registerGroup
|
||||
VimPlugin.getRegister()
|
||||
.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
text rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
VimPlugin.getRegister()
|
||||
.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
text rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("viw" + "gr"))
|
||||
assertState(
|
||||
"""
|
||||
@ -515,15 +527,17 @@ class ReplaceWithRegisterTest : VimTestCase() {
|
||||
configureByText(text)
|
||||
val vimEditor = fixture.editor.vim
|
||||
val context = injector.executionContextManager.getEditorExecutionContext(vimEditor)
|
||||
VimPlugin.getRegister()
|
||||
.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
text rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
VimPlugin.getRegister()
|
||||
.storeText(
|
||||
vimEditor,
|
||||
context,
|
||||
vimEditor.primaryCaret(),
|
||||
text rangeOf "legendary",
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false
|
||||
)
|
||||
}
|
||||
typeText(injector.parser.parseKeys("V" + "gr"))
|
||||
assertState(
|
||||
"""
|
||||
|
@ -9,6 +9,7 @@
|
||||
package org.jetbrains.plugins.ideavim.group
|
||||
|
||||
import com.intellij.idea.TestFor
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.action.motion.search.SearchWholeWordForwardAction
|
||||
@ -915,16 +916,20 @@ class SearchGroupTest : VimTestCase() {
|
||||
val project = fixture.project
|
||||
val searchGroup = VimPlugin.getSearch()
|
||||
val ref = Ref.create(-1)
|
||||
RunnableHelper.runReadCommand(
|
||||
project,
|
||||
{
|
||||
// Does not move the caret!
|
||||
val n = searchGroup.processSearchCommand(editor.vim, pattern, fixture.caretOffset, 1, Direction.FORWARDS)
|
||||
ref.set(n?.first ?: -1)
|
||||
},
|
||||
null,
|
||||
null,
|
||||
)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
ApplicationManager.getApplication().runWriteIntentReadAction<Any, Throwable> {
|
||||
RunnableHelper.runReadCommand(
|
||||
project,
|
||||
{
|
||||
// Does not move the caret!
|
||||
val n = searchGroup.processSearchCommand(editor.vim, pattern, fixture.caretOffset, 1, Direction.FORWARDS)
|
||||
ref.set(n?.first ?: -1)
|
||||
},
|
||||
null,
|
||||
null,
|
||||
)
|
||||
}
|
||||
}
|
||||
return ref.get()
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.group.motion
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
@ -106,9 +107,11 @@ class MotionGroup_ScrollCaretIntoViewHorizontally_Test : VimTestCase() {
|
||||
typeText("100|", "20l")
|
||||
// These columns are hard to calculate, because the visible offset depends on the rendered width of the inlay
|
||||
// Also, because we're scrolling right (adding columns to the right) we make the right most column line up
|
||||
val textWidth = fixture.editor.scrollingModel.visibleArea.width - inlay.widthInPixels
|
||||
val availableColumns = (textWidth / EditorHelper.getPlainSpaceWidthFloat(fixture.editor)).roundToInt()
|
||||
assertVisibleLineBounds(0, 119 - availableColumns + 1, 119)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
val textWidth = fixture.editor.scrollingModel.visibleArea.width - inlay.widthInPixels
|
||||
val availableColumns = (textWidth / EditorHelper.getPlainSpaceWidthFloat(fixture.editor)).roundToInt()
|
||||
assertVisibleLineBounds(0, 119 - availableColumns + 1, 119)
|
||||
}
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.SCROLL)
|
||||
@ -190,9 +193,11 @@ class MotionGroup_ScrollCaretIntoViewHorizontally_Test : VimTestCase() {
|
||||
val inlay = addInlay(110, true, 5)
|
||||
typeText("120|zs", "20h")
|
||||
// These columns are hard to calculate, because the visible offset depends on the rendered width of the inlay
|
||||
val textWidth = fixture.editor.scrollingModel.visibleArea.width - inlay.widthInPixels
|
||||
val availableColumns = (textWidth / EditorHelper.getPlainSpaceWidthFloat(fixture.editor)).roundToInt()
|
||||
assertVisibleLineBounds(0, 99, 99 + availableColumns - 1)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
val textWidth = fixture.editor.scrollingModel.visibleArea.width - inlay.widthInPixels
|
||||
val availableColumns = (textWidth / EditorHelper.getPlainSpaceWidthFloat(fixture.editor)).roundToInt()
|
||||
assertVisibleLineBounds(0, 99, 99 + availableColumns - 1)
|
||||
}
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.SCROLL)
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.group.motion
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
@ -255,6 +256,8 @@ class MotionGroup_ScrollCaretIntoViewVertically_Test : VimTestCase() {
|
||||
}
|
||||
|
||||
private fun assertVisualLineAtMiddleOfScreen(expected: Int) {
|
||||
kotlin.test.assertEquals(expected, EditorHelper.getVisualLineAtMiddleOfScreen(fixture.editor))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
kotlin.test.assertEquals(expected, EditorHelper.getVisualLineAtMiddleOfScreen(fixture.editor))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ package org.jetbrains.plugins.ideavim.group.visual
|
||||
import com.intellij.codeInsight.template.TemplateManager
|
||||
import com.intellij.codeInsight.template.impl.ConstantNode
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.group.visual.IdeaSelectionControl
|
||||
import com.maddyhome.idea.vim.group.visual.VimVisualTimer
|
||||
@ -691,7 +692,9 @@ class IdeaVisualControlTest : VimTestCase() {
|
||||
VimListenerManager.EditorListeners.addAll()
|
||||
assertMode(Mode.NORMAL())
|
||||
|
||||
fixture.editor.selectionModel.setSelection(5, 10)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.selectionModel.setSelection(5, 10)
|
||||
}
|
||||
|
||||
waitAndAssertMode(fixture, Mode.SELECT(SelectionType.CHARACTER_WISE))
|
||||
}
|
||||
@ -710,7 +713,9 @@ class IdeaVisualControlTest : VimTestCase() {
|
||||
VimListenerManager.EditorListeners.addAll()
|
||||
assertMode(Mode.NORMAL())
|
||||
|
||||
fixture.editor.selectionModel.setSelection(5, 10)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.selectionModel.setSelection(5, 10)
|
||||
}
|
||||
|
||||
waitAndAssertMode(fixture, Mode.VISUAL(SelectionType.CHARACTER_WISE))
|
||||
}
|
||||
@ -729,7 +734,9 @@ class IdeaVisualControlTest : VimTestCase() {
|
||||
typeText(injector.parser.parseKeys("V"))
|
||||
assertMode(Mode.VISUAL(SelectionType.LINE_WISE))
|
||||
|
||||
fixture.editor.selectionModel.setSelection(2, 5)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.selectionModel.setSelection(2, 5)
|
||||
}
|
||||
IdeaSelectionControl.controlNonVimSelectionChange(fixture.editor)
|
||||
|
||||
waitAndAssert { fixture.editor.vim.mode.selectionType == SelectionType.CHARACTER_WISE }
|
||||
@ -751,17 +758,21 @@ class IdeaVisualControlTest : VimTestCase() {
|
||||
|
||||
startDummyTemplate()
|
||||
|
||||
VimVisualTimer.doNow()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
VimVisualTimer.doNow()
|
||||
}
|
||||
|
||||
typeText(injector.parser.parseKeys("<esc>V"))
|
||||
assertMode(Mode.VISUAL(SelectionType.LINE_WISE))
|
||||
|
||||
fixture.editor.selectionModel.setSelection(2, 5)
|
||||
IdeaSelectionControl.controlNonVimSelectionChange(fixture.editor)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.selectionModel.setSelection(2, 5)
|
||||
IdeaSelectionControl.controlNonVimSelectionChange(fixture.editor)
|
||||
|
||||
waitAndAssert { fixture.editor.vim.mode.selectionType == SelectionType.CHARACTER_WISE }
|
||||
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
|
||||
assertCaretsVisualAttributes()
|
||||
waitAndAssert { fixture.editor.vim.mode.selectionType == SelectionType.CHARACTER_WISE }
|
||||
assertMode(Mode.VISUAL(SelectionType.CHARACTER_WISE))
|
||||
assertCaretsVisualAttributes()
|
||||
}
|
||||
}
|
||||
|
||||
@OptionTest(VimOption(TestOptionConstants.selectmode, limitedValues = [""]))
|
||||
@ -782,10 +793,14 @@ class IdeaVisualControlTest : VimTestCase() {
|
||||
}
|
||||
|
||||
private fun startDummyTemplate() {
|
||||
TemplateManagerImpl.setTemplateTesting(fixture.testRootDisposable)
|
||||
val templateManager = TemplateManager.getInstance(fixture.project)
|
||||
val createdTemplate = templateManager.createTemplate("", "")
|
||||
createdTemplate.addVariable(ConstantNode("1"), true)
|
||||
templateManager.startTemplate(fixture.editor, createdTemplate)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
ApplicationManager.getApplication().runWriteIntentReadAction<Any, Throwable> {
|
||||
TemplateManagerImpl.setTemplateTesting(fixture.testRootDisposable)
|
||||
val templateManager = TemplateManager.getInstance(fixture.project)
|
||||
val createdTemplate = templateManager.createTemplate("", "")
|
||||
createdTemplate.addVariable(ConstantNode("1"), true)
|
||||
templateManager.startTemplate(fixture.editor, createdTemplate)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,9 +47,11 @@ class NonVimVisualChangeTest : VimTestCase() {
|
||||
)
|
||||
typeText("i")
|
||||
assertMode(Mode.INSERT)
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
CommandProcessor.getInstance().runUndoTransparentAction {
|
||||
BackspaceHandler.deleteToTargetPosition(fixture.editor, LogicalPosition(2, 0))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
CommandProcessor.getInstance().runUndoTransparentAction {
|
||||
BackspaceHandler.deleteToTargetPosition(fixture.editor, LogicalPosition(2, 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
assertState(
|
||||
@ -82,8 +84,10 @@ class NonVimVisualChangeTest : VimTestCase() {
|
||||
assertMode(Mode.INSERT)
|
||||
|
||||
// Fast add and remove selection
|
||||
fixture.editor.selectionModel.setSelection(0, 10)
|
||||
fixture.editor.selectionModel.removeSelection()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.selectionModel.setSelection(0, 10)
|
||||
fixture.editor.selectionModel.removeSelection()
|
||||
}
|
||||
|
||||
assertDoesntChange { fixture.editor.vim.mode == Mode.INSERT }
|
||||
}
|
||||
@ -105,9 +109,11 @@ class NonVimVisualChangeTest : VimTestCase() {
|
||||
assertMode(Mode.INSERT)
|
||||
|
||||
// Fast add and remove selection
|
||||
fixture.editor.selectionModel.setSelection(0, 10)
|
||||
fixture.editor.selectionModel.removeSelection()
|
||||
fixture.editor.selectionModel.setSelection(0, 10)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.selectionModel.setSelection(0, 10)
|
||||
fixture.editor.selectionModel.removeSelection()
|
||||
fixture.editor.selectionModel.setSelection(0, 10)
|
||||
}
|
||||
|
||||
waitAndAssertMode(fixture, Mode.VISUAL(SelectionType.CHARACTER_WISE))
|
||||
}
|
||||
@ -128,12 +134,16 @@ class NonVimVisualChangeTest : VimTestCase() {
|
||||
assertMode(Mode.INSERT)
|
||||
|
||||
val range = text.rangeOf("Discovery")
|
||||
fixture.editor.selectionModel.setSelection(range.startOffset, range.endOffset)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.selectionModel.setSelection(range.startOffset, range.endOffset)
|
||||
}
|
||||
waitAndAssertMode(fixture, Mode.VISUAL(SelectionType.CHARACTER_WISE))
|
||||
assertEquals(SelectionType.CHARACTER_WISE, fixture.editor.vim.mode.selectionType)
|
||||
|
||||
val rangeLine = text.rangeOf("A Discovery\n")
|
||||
fixture.editor.selectionModel.setSelection(rangeLine.startOffset, rangeLine.endOffset)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.selectionModel.setSelection(rangeLine.startOffset, rangeLine.endOffset)
|
||||
}
|
||||
waitAndAssert { fixture.editor.vim.mode.selectionType == SelectionType.LINE_WISE }
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.helper
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.CaretVisualAttributes
|
||||
import com.intellij.openapi.editor.VisualPosition
|
||||
@ -330,9 +331,11 @@ class CaretVisualAttributesHelperTest : VimTestCase() {
|
||||
@TestWithoutNeovim(SkipNeovimReason.NOT_VIM_TESTING)
|
||||
@Test
|
||||
fun `test adding new caret via IJ`() {
|
||||
configureByText("${c}Lorem ipsum dolor sit amet,")
|
||||
fixture.editor.caretModel.addCaret(VisualPosition(0, 5))
|
||||
assertCaretVisualAttributes(CaretVisualAttributes.Shape.BLOCK, 0f)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
configureByText("${c}Lorem ipsum dolor sit amet,")
|
||||
fixture.editor.caretModel.addCaret(VisualPosition(0, 5))
|
||||
assertCaretVisualAttributes(CaretVisualAttributes.Shape.BLOCK, 0f)
|
||||
}
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.NOT_VIM_TESTING)
|
||||
@ -344,13 +347,15 @@ class CaretVisualAttributesHelperTest : VimTestCase() {
|
||||
|consectetur adipiscing elit
|
||||
""".trimMargin(),
|
||||
)
|
||||
injector.actionExecutor.executeAction(
|
||||
fixture.editor.vim,
|
||||
name = "EditorCloneCaretBelow",
|
||||
context = injector.executionContextManager.getEditorExecutionContext(fixture.editor.vim),
|
||||
)
|
||||
kotlin.test.assertEquals(2, fixture.editor.caretModel.caretCount)
|
||||
assertCaretVisualAttributes(CaretVisualAttributes.Shape.BLOCK, 0f)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
injector.actionExecutor.executeAction(
|
||||
fixture.editor.vim,
|
||||
name = "EditorCloneCaretBelow",
|
||||
context = injector.executionContextManager.getEditorExecutionContext(fixture.editor.vim),
|
||||
)
|
||||
kotlin.test.assertEquals(2, fixture.editor.caretModel.caretCount)
|
||||
assertCaretVisualAttributes(CaretVisualAttributes.Shape.BLOCK, 0f)
|
||||
}
|
||||
}
|
||||
|
||||
private fun assertCaretVisualAttributes(expectedShape: CaretVisualAttributes.Shape, expectedThickness: Float) {
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.helper
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||
@ -21,10 +22,12 @@ class EditorHelperTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test scroll column to left of screen`() {
|
||||
configureByColumns(100)
|
||||
EditorHelper.scrollColumnToLeftOfScreen(fixture.editor, 0, 2)
|
||||
val visibleArea = fixture.editor.scrollingModel.visibleArea
|
||||
val columnWidth = EditorHelper.getPlainSpaceWidthFloat(fixture.editor)
|
||||
assertEquals((2 * columnWidth).roundToInt(), visibleArea.x)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorHelper.scrollColumnToLeftOfScreen(fixture.editor, 0, 2)
|
||||
val visibleArea = fixture.editor.scrollingModel.visibleArea
|
||||
val columnWidth = EditorHelper.getPlainSpaceWidthFloat(fixture.editor)
|
||||
assertEquals((2 * columnWidth).roundToInt(), visibleArea.x)
|
||||
}
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.NOT_VIM_TESTING)
|
||||
@ -32,10 +35,12 @@ class EditorHelperTest : VimTestCase() {
|
||||
fun `test scroll column to right of screen`() {
|
||||
configureByColumns(100)
|
||||
val column = screenWidth + 2
|
||||
EditorHelper.scrollColumnToRightOfScreen(fixture.editor, 0, column)
|
||||
val visibleArea = fixture.editor.scrollingModel.visibleArea
|
||||
val columnWidth = EditorHelper.getPlainSpaceWidthFloat(fixture.editor)
|
||||
assertEquals(((column - screenWidth + 1) * columnWidth).roundToInt(), visibleArea.x)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorHelper.scrollColumnToRightOfScreen(fixture.editor, 0, column)
|
||||
val visibleArea = fixture.editor.scrollingModel.visibleArea
|
||||
val columnWidth = EditorHelper.getPlainSpaceWidthFloat(fixture.editor)
|
||||
assertEquals(((column - screenWidth + 1) * columnWidth).roundToInt(), visibleArea.x)
|
||||
}
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.NOT_VIM_TESTING)
|
||||
@ -45,10 +50,12 @@ class EditorHelperTest : VimTestCase() {
|
||||
// For an 80 column screen, moving a column to the centre should position it in column 41 (1 based) - 40 columns on
|
||||
// the left, mid point, 39 columns on the right
|
||||
// Put column 100 into position 41 -> offset is 59 columns
|
||||
EditorHelper.scrollColumnToMiddleOfScreen(fixture.editor, 0, 99)
|
||||
val visibleArea = fixture.editor.scrollingModel.visibleArea
|
||||
val columnWidth = EditorHelper.getPlainSpaceWidthFloat(fixture.editor)
|
||||
assertEquals((59 * columnWidth).roundToInt(), visibleArea.x)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorHelper.scrollColumnToMiddleOfScreen(fixture.editor, 0, 99)
|
||||
val visibleArea = fixture.editor.scrollingModel.visibleArea
|
||||
val columnWidth = EditorHelper.getPlainSpaceWidthFloat(fixture.editor)
|
||||
assertEquals((59 * columnWidth).roundToInt(), visibleArea.x)
|
||||
}
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(SkipNeovimReason.NOT_VIM_TESTING)
|
||||
@ -59,9 +66,11 @@ class EditorHelperTest : VimTestCase() {
|
||||
// For an 81 column screen, moving a column to the centre should position it in column 41 (1 based) - 40 columns on
|
||||
// the left, mid point, 40 columns on the right
|
||||
// Put column 100 into position 41 -> offset is 59 columns
|
||||
EditorHelper.scrollColumnToMiddleOfScreen(fixture.editor, 0, 99)
|
||||
val visibleArea = fixture.editor.scrollingModel.visibleArea
|
||||
val columnWidth = EditorHelper.getPlainSpaceWidthFloat(fixture.editor)
|
||||
assertEquals((59 * columnWidth).roundToInt(), visibleArea.x)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorHelper.scrollColumnToMiddleOfScreen(fixture.editor, 0, 99)
|
||||
val visibleArea = fixture.editor.scrollingModel.visibleArea
|
||||
val columnWidth = EditorHelper.getPlainSpaceWidthFloat(fixture.editor)
|
||||
assertEquals((59 * columnWidth).roundToInt(), visibleArea.x)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.ideavim.helper
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.group.findBlockRange
|
||||
@ -104,8 +105,10 @@ class SearchHelperTest : VimTestCase() {
|
||||
fun findBlockRange(testCase: FindBlockRangeTestCase) {
|
||||
val (_, text, type, count, isOuter, expected) = (testCase)
|
||||
configureByText(text)
|
||||
val actual = findBlockRange(fixture.editor.vim, fixture.editor.vim.currentCaret(), type, count, isOuter)
|
||||
kotlin.test.assertEquals(expected, actual)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
val actual = findBlockRange(fixture.editor.vim, fixture.editor.vim.currentCaret(), type, count, isOuter)
|
||||
kotlin.test.assertEquals(expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.listener
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.ComponentManagerEx
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
|
||||
@ -66,7 +67,9 @@ class VimListenersTest : VimTestCase() {
|
||||
configureByText("XYZ")
|
||||
|
||||
val fileManager = FileEditorManagerEx.getInstanceEx(fixture.project)
|
||||
fileManager.closeFile(fixture.editor.virtualFile)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fileManager.closeFile(fixture.editor.virtualFile)
|
||||
}
|
||||
|
||||
assertEquals(1, VimListenerTestObject.disposedCounter)
|
||||
}
|
||||
@ -80,7 +83,9 @@ class VimListenersTest : VimTestCase() {
|
||||
assertEquals(1, VimListenerTestObject.disposedCounter)
|
||||
|
||||
val fileManager = FileEditorManagerEx.getInstanceEx(fixture.project)
|
||||
fileManager.closeFile(fixture.editor.virtualFile)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fileManager.closeFile(fixture.editor.virtualFile)
|
||||
}
|
||||
|
||||
assertEquals(1, VimListenerTestObject.disposedCounter)
|
||||
} finally {
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.option.overrides
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
|
||||
@ -38,7 +39,9 @@ class BreakIndentOptionMapperTest : VimTestCase() {
|
||||
@Suppress("SameParameterValue")
|
||||
private fun switchToNewFile(filename: String, content: String) {
|
||||
// This replaces fixture.editor
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
}
|
||||
|
||||
// But our selection changed callback doesn't get called immediately, and that callback will deactivate the ex entry
|
||||
// panel (which causes problems if our next command is `:set`). So type something (`0` is a good no-op) to give time
|
||||
@ -172,7 +175,11 @@ class BreakIndentOptionMapperTest : VimTestCase() {
|
||||
fun `test setting global IDE value will update effective Vim value set during plugin startup`() {
|
||||
// Default value is false. Update the global value to something different, but make sure the Vim options are default
|
||||
EditorSettingsExternalizable.getInstance().isUseCustomSoftWrapIndent = true
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
@ -293,7 +300,11 @@ class BreakIndentOptionMapperTest : VimTestCase() {
|
||||
fun `test setting global IDE value will update effective Vim value in new window initialised from value set during startup`() {
|
||||
// Default value is false. Update the global value to something different, but make sure the Vim options are default
|
||||
EditorSettingsExternalizable.getInstance().isUseCustomSoftWrapIndent = true
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
|
@ -10,6 +10,7 @@ package org.jetbrains.plugins.ideavim.option.overrides
|
||||
|
||||
import com.intellij.application.options.CodeStyle
|
||||
import com.intellij.lang.Language
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||
import com.intellij.openapi.editor.impl.SettingsImpl
|
||||
@ -42,7 +43,9 @@ class ColorColumnOptionMapperTest : VimTestCase() {
|
||||
@Suppress("SameParameterValue")
|
||||
private fun openNewBufferWindow(filename: String, content: String): Editor {
|
||||
// This replaces fixture.editor
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
}
|
||||
|
||||
// But our selection changed callback doesn't get called immediately, and that callback will deactivate the ex entry
|
||||
// panel (which causes problems if our next command is `:set`). So type something (`0` is a good no-op) to give time
|
||||
@ -100,93 +103,109 @@ class ColorColumnOptionMapperTest : VimTestCase() {
|
||||
fun `test 'colorcolumn' reports '+0' to show right margin is visible`() {
|
||||
// IntelliJ only has one setting for visual guides and hard-wrap typing margin, so we have to report a special value
|
||||
// of "+0", which makes Vim show a highlight column at 'textwidth' (IntelliJ shows it even if 'textwidth' is 0)
|
||||
fixture.editor.settings.isRightMarginShown = true
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=+0")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isRightMarginShown = true
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=+0")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test 'colorcolumn' reports '+0' at end of visual guide list`() {
|
||||
fixture.editor.settings.isRightMarginShown = true
|
||||
fixture.editor.settings.setSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=10,20,30,+0")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isRightMarginShown = true
|
||||
fixture.editor.settings.setSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=10,20,30,+0")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test 'colorcolumn' option reports global intellij setting if not explicitly set`() {
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = true
|
||||
setGlobalSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=10,20,30,+0")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = true
|
||||
setGlobalSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=10,20,30,+0")
|
||||
|
||||
setGlobalSoftMargins(listOf(90, 80, 70))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=70,80,90,+0")
|
||||
setGlobalSoftMargins(listOf(90, 80, 70))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=70,80,90,+0")
|
||||
|
||||
setGlobalSoftMargins(emptyList())
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=+0")
|
||||
setGlobalSoftMargins(emptyList())
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=+0")
|
||||
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = false
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=")
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = false
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test local 'colorcolumn' option reports global intellij setting if not explicitly set`() {
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = true
|
||||
setGlobalSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=10,20,30,+0")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = true
|
||||
setGlobalSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=10,20,30,+0")
|
||||
|
||||
setGlobalSoftMargins(listOf(90, 80, 70))
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=70,80,90,+0")
|
||||
setGlobalSoftMargins(listOf(90, 80, 70))
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=70,80,90,+0")
|
||||
|
||||
setGlobalSoftMargins(emptyList())
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=+0")
|
||||
setGlobalSoftMargins(emptyList())
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=+0")
|
||||
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = false
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=")
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = false
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test 'colorcolumn' option reports local intellij setting if set via IDE`() {
|
||||
fixture.editor.settings.isRightMarginShown = true
|
||||
fixture.editor.settings.setSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=10,20,30,+0")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isRightMarginShown = true
|
||||
fixture.editor.settings.setSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=10,20,30,+0")
|
||||
|
||||
fixture.editor.settings.setSoftMargins(listOf(70, 80, 90))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=70,80,90,+0")
|
||||
fixture.editor.settings.setSoftMargins(listOf(70, 80, 90))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=70,80,90,+0")
|
||||
|
||||
fixture.editor.settings.setSoftMargins(emptyList())
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=+0")
|
||||
fixture.editor.settings.setSoftMargins(emptyList())
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=+0")
|
||||
|
||||
fixture.editor.settings.isRightMarginShown = false
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=")
|
||||
fixture.editor.settings.isRightMarginShown = false
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test local 'colorcolumn' option reports local intellij setting if set via IDE`() {
|
||||
fixture.editor.settings.isRightMarginShown = true
|
||||
fixture.editor.settings.setSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=10,20,30,+0")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isRightMarginShown = true
|
||||
fixture.editor.settings.setSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=10,20,30,+0")
|
||||
|
||||
fixture.editor.settings.setSoftMargins(listOf(70, 80, 90))
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=70,80,90,+0")
|
||||
fixture.editor.settings.setSoftMargins(listOf(70, 80, 90))
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=70,80,90,+0")
|
||||
|
||||
fixture.editor.settings.setSoftMargins(emptyList())
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=+0")
|
||||
fixture.editor.settings.setSoftMargins(emptyList())
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=+0")
|
||||
|
||||
fixture.editor.settings.isRightMarginShown = false
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=")
|
||||
fixture.editor.settings.isRightMarginShown = false
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test 'colorcolumn' does not report current visual guides if global right margin option is disabled`() {
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = false
|
||||
fixture.editor.settings.setSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = false
|
||||
fixture.editor.settings.setSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test 'colorcolumn' does not report current visual guides if local right margin option is disabled`() {
|
||||
fixture.editor.settings.isRightMarginShown = false
|
||||
fixture.editor.settings.setSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isRightMarginShown = false
|
||||
fixture.editor.settings.setSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -260,8 +279,10 @@ class ColorColumnOptionMapperTest : VimTestCase() {
|
||||
fun `test setting IDE value is treated like setlocal`() {
|
||||
// If we use `:set`, it updates the local and per-window global values. If we set the value from the IDE, it only
|
||||
// affects the local value
|
||||
fixture.editor.settings.isRightMarginShown = true
|
||||
fixture.editor.settings.setSoftMargins(listOf(70, 80, 90))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isRightMarginShown = true
|
||||
fixture.editor.settings.setSoftMargins(listOf(70, 80, 90))
|
||||
}
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=70,80,90,+0")
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=70,80,90,+0")
|
||||
assertCommandOutput("setglobal colorcolumn?", " colorcolumn=")
|
||||
@ -282,66 +303,74 @@ class ColorColumnOptionMapperTest : VimTestCase() {
|
||||
|
||||
@Test
|
||||
fun `test reset 'colorcolun' to default copies current global intellij setting`() {
|
||||
fixture.editor.settings.isRightMarginShown = true
|
||||
fixture.editor.settings.setSoftMargins(listOf(10, 20, 30))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isRightMarginShown = true
|
||||
fixture.editor.settings.setSoftMargins(listOf(10, 20, 30))
|
||||
|
||||
enterCommand("set colorcolumn&")
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=")
|
||||
assertFalse(fixture.editor.settings.isRightMarginShown)
|
||||
assertEmpty(fixture.editor.settings.softMargins)
|
||||
enterCommand("set colorcolumn&")
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=")
|
||||
assertFalse(fixture.editor.settings.isRightMarginShown)
|
||||
assertEmpty(fixture.editor.settings.softMargins)
|
||||
|
||||
// Verify that IntelliJ doesn't allow us to "unset" a local editor setting - it's a copy of the global value
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = true
|
||||
assertFalse(fixture.editor.settings.isRightMarginShown)
|
||||
// Verify that IntelliJ doesn't allow us to "unset" a local editor setting - it's a copy of the global value
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = true
|
||||
assertFalse(fixture.editor.settings.isRightMarginShown)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test reset local 'colorcolun' to default copies current global intellij setting`() {
|
||||
fixture.editor.settings.isRightMarginShown = true
|
||||
fixture.editor.settings.setSoftMargins(listOf(10, 20, 30))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isRightMarginShown = true
|
||||
fixture.editor.settings.setSoftMargins(listOf(10, 20, 30))
|
||||
|
||||
enterCommand("setlocal colorcolumn&")
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=")
|
||||
assertFalse(fixture.editor.settings.isRightMarginShown)
|
||||
assertEmpty(fixture.editor.settings.softMargins)
|
||||
enterCommand("setlocal colorcolumn&")
|
||||
assertCommandOutput("setlocal colorcolumn?", " colorcolumn=")
|
||||
assertFalse(fixture.editor.settings.isRightMarginShown)
|
||||
assertEmpty(fixture.editor.settings.softMargins)
|
||||
|
||||
// Verify that IntelliJ doesn't allow us to "unset" a local editor setting - it's a copy of the global value
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = true
|
||||
assertFalse(fixture.editor.settings.isRightMarginShown)
|
||||
// Verify that IntelliJ doesn't allow us to "unset" a local editor setting - it's a copy of the global value
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = true
|
||||
assertFalse(fixture.editor.settings.isRightMarginShown)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test open new window without setting ideavim option will initialise 'colorcolumn' to defaults`() {
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = true
|
||||
setGlobalSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=10,20,30,+0")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = true
|
||||
setGlobalSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=10,20,30,+0")
|
||||
|
||||
openNewBufferWindow("bbb.txt", "lorem ipsum")
|
||||
openNewBufferWindow("bbb.txt", "lorem ipsum")
|
||||
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=10,20,30,+0")
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=10,20,30,+0")
|
||||
|
||||
// Changing the global value should update the editor
|
||||
setGlobalSoftMargins(listOf(40, 50, 60, 70))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=40,50,60,70,+0")
|
||||
// Changing the global value should update the editor
|
||||
setGlobalSoftMargins(listOf(40, 50, 60, 70))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=40,50,60,70,+0")
|
||||
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = false
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=")
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = false
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test open new window after setting ideavim option will initialise 'colorcolumn' to setglobal value`() {
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = true
|
||||
setGlobalSoftMargins(listOf(10, 20, 30))
|
||||
enterCommand("set colorcolumn=40,50,60")
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=40,50,60,+0")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isRightMarginShown = true
|
||||
setGlobalSoftMargins(listOf(10, 20, 30))
|
||||
enterCommand("set colorcolumn=40,50,60")
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=40,50,60,+0")
|
||||
|
||||
openNewBufferWindow("bbb.txt", "lorem ipsum")
|
||||
openNewBufferWindow("bbb.txt", "lorem ipsum")
|
||||
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=40,50,60,+0")
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=40,50,60,+0")
|
||||
|
||||
// Changing the global value should NOT update the editor
|
||||
setGlobalSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=40,50,60,+0")
|
||||
// Changing the global value should NOT update the editor
|
||||
setGlobalSoftMargins(listOf(10, 20, 30))
|
||||
assertCommandOutput("set colorcolumn?", " colorcolumn=40,50,60,+0")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -358,19 +387,25 @@ class ColorColumnOptionMapperTest : VimTestCase() {
|
||||
}
|
||||
|
||||
private fun getGlobalSoftMargins(): List<Int> {
|
||||
val language = TextEditorImpl.getDocumentLanguage(fixture.editor)
|
||||
return CodeStyle.getSettings(fixture.editor).getSoftMargins(language)
|
||||
var res: List<Int>? = null
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
val language = TextEditorImpl.getDocumentLanguage(fixture.editor)
|
||||
res = CodeStyle.getSettings(fixture.editor).getSoftMargins(language)
|
||||
}
|
||||
return res!!
|
||||
}
|
||||
|
||||
private fun setGlobalSoftMargins(margins: List<Int>) {
|
||||
val language = TextEditorImpl.getDocumentLanguage(fixture.editor)
|
||||
val commonSettings = CodeStyle.getSettings(fixture.editor).getCommonSettings(language)
|
||||
if (language == null || commonSettings.language == Language.ANY) {
|
||||
CodeStyle.getSettings(fixture.editor).defaultSoftMargins = margins
|
||||
} else {
|
||||
CodeStyle.getSettings(fixture.editor).setSoftMargins(language, margins)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
val language = TextEditorImpl.getDocumentLanguage(fixture.editor)
|
||||
val commonSettings = CodeStyle.getSettings(fixture.editor).getCommonSettings(language)
|
||||
if (language == null || commonSettings.language == Language.ANY) {
|
||||
CodeStyle.getSettings(fixture.editor).defaultSoftMargins = margins
|
||||
} else {
|
||||
CodeStyle.getSettings(fixture.editor).setSoftMargins(language, margins)
|
||||
}
|
||||
// Setting the value directly doesn't invalidate the cached property value. Not sure if there's a better way
|
||||
(fixture.editor.settings as SettingsImpl).reinitSettings()
|
||||
}
|
||||
// Setting the value directly doesn't invalidate the cached property value. Not sure if there's a better way
|
||||
(fixture.editor.settings as SettingsImpl).reinitSettings()
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.option.overrides
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||
import com.intellij.openapi.editor.impl.SettingsImpl
|
||||
import com.maddyhome.idea.vim.group.IjOptions
|
||||
@ -32,7 +33,9 @@ class CursorLineOptionMapperTest : VimTestCase() {
|
||||
@Suppress("SameParameterValue")
|
||||
private fun switchToNewFile(filename: String, content: String) {
|
||||
// This replaces fixture.editor
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
}
|
||||
|
||||
// But our selection changed callback doesn't get called immediately, and that callback will deactivate the ex entry
|
||||
// panel (which causes problems if our next command is `:set`). So type something (`0` is a good no-op) to give time
|
||||
@ -48,41 +51,51 @@ class CursorLineOptionMapperTest : VimTestCase() {
|
||||
|
||||
@Test
|
||||
fun `test 'cursorline' defaults to global intellij setting`() {
|
||||
(fixture.editor.settings as SettingsImpl).getState().apply { clearOverriding(this::myCaretRowShown) }
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isCaretRowShown)
|
||||
assertTrue(optionsIj().cursorline)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
(fixture.editor.settings as SettingsImpl).getState().apply { clearOverriding(this::myCaretRowShown) }
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isCaretRowShown)
|
||||
assertTrue(optionsIj().cursorline)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test 'cursorline' option reports global intellij setting if not explicitly set`() {
|
||||
(fixture.editor.settings as SettingsImpl).getState().apply { clearOverriding(this::myCaretRowShown) }
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
(fixture.editor.settings as SettingsImpl).getState().apply { clearOverriding(this::myCaretRowShown) }
|
||||
}
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isCaretRowShown)
|
||||
assertCommandOutput("set cursorline?", " cursorline")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test local 'cursorline' option reports global intellij setting if not explicitly set`() {
|
||||
(fixture.editor.settings as SettingsImpl).getState().apply { clearOverriding(this::myCaretRowShown) }
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isCaretRowShown)
|
||||
assertCommandOutput("setlocal cursorline?", " cursorline")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
(fixture.editor.settings as SettingsImpl).getState().apply { clearOverriding(this::myCaretRowShown) }
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isCaretRowShown)
|
||||
assertCommandOutput("setlocal cursorline?", " cursorline")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test 'cursorline' option reports local intellij setting if set via IDE`() {
|
||||
fixture.editor.settings.isCaretRowShown = false
|
||||
assertCommandOutput("set cursorline?", "nocursorline")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isCaretRowShown = false
|
||||
assertCommandOutput("set cursorline?", "nocursorline")
|
||||
|
||||
fixture.editor.settings.isCaretRowShown = true
|
||||
assertCommandOutput("set cursorline?", " cursorline")
|
||||
fixture.editor.settings.isCaretRowShown = true
|
||||
assertCommandOutput("set cursorline?", " cursorline")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test local 'cursorline' option reports local intellij setting if set via IDE`() {
|
||||
fixture.editor.settings.isCaretRowShown = false
|
||||
assertCommandOutput("setlocal cursorline?", "nocursorline")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isCaretRowShown = false
|
||||
assertCommandOutput("setlocal cursorline?", "nocursorline")
|
||||
|
||||
fixture.editor.settings.isCaretRowShown = true
|
||||
assertCommandOutput("setlocal cursorline?", " cursorline")
|
||||
fixture.editor.settings.isCaretRowShown = true
|
||||
assertCommandOutput("setlocal cursorline?", " cursorline")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -184,14 +197,16 @@ class CursorLineOptionMapperTest : VimTestCase() {
|
||||
fun `test open new window without setting the option copies value as not-explicitly set`() {
|
||||
// New window will clone local and global local-to-window options, then apply global to local. This tests that our
|
||||
// handling of per-window "global" values is correct.
|
||||
(fixture.editor.settings as SettingsImpl).getState().apply { clearOverriding(this::myCaretRowShown) }
|
||||
assertCommandOutput("set cursorline?", " cursorline")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
(fixture.editor.settings as SettingsImpl).getState().apply { clearOverriding(this::myCaretRowShown) }
|
||||
assertCommandOutput("set cursorline?", " cursorline")
|
||||
|
||||
switchToNewFile("bbb.txt", "lorem ipsum")
|
||||
switchToNewFile("bbb.txt", "lorem ipsum")
|
||||
|
||||
assertCommandOutput("set cursorline?", " cursorline")
|
||||
assertCommandOutput("set cursorline?", " cursorline")
|
||||
|
||||
// Can't prove that it was copied as a default value because we can't change the global value
|
||||
// Can't prove that it was copied as a default value because we can't change the global value
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.option.overrides
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.EditorSettings.LineNumerationType
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
|
||||
@ -40,7 +41,9 @@ class LineNumberOptionsMapperTest : VimTestCase() {
|
||||
@Suppress("SameParameterValue")
|
||||
private fun switchToNewFile(filename: String, content: String) {
|
||||
// This replaces fixture.editor
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
}
|
||||
|
||||
// But our selection changed callback doesn't get called immediately, and that callback will deactivate the ex entry
|
||||
// panel (which causes problems if our next command is `:set`). So type something (`0` is a good no-op) to give time
|
||||
@ -64,26 +67,30 @@ class LineNumberOptionsMapperTest : VimTestCase() {
|
||||
|
||||
@Test
|
||||
fun `test 'number' and 'relativenumber' options reports global intellij setting if not explicitly set`() {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertCommandOutput("set number?", "nonumber")
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertCommandOutput("set number?", "nonumber")
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.HYBRID
|
||||
assertCommandOutput("set number?", " number")
|
||||
assertCommandOutput("set relativenumber?", " relativenumber")
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.HYBRID
|
||||
assertCommandOutput("set number?", " number")
|
||||
assertCommandOutput("set relativenumber?", " relativenumber")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test local 'number' and 'relativenumber' options reports global intellij setting if not explicitly set`() {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertCommandOutput("setlocal number?", "nonumber")
|
||||
assertCommandOutput("setlocal relativenumber?", "norelativenumber")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertCommandOutput("setlocal number?", "nonumber")
|
||||
assertCommandOutput("setlocal relativenumber?", "norelativenumber")
|
||||
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.HYBRID
|
||||
assertCommandOutput("setlocal number?", " number")
|
||||
assertCommandOutput("setlocal relativenumber?", " relativenumber")
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.HYBRID
|
||||
assertCommandOutput("setlocal number?", " number")
|
||||
assertCommandOutput("setlocal relativenumber?", " relativenumber")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -93,39 +100,43 @@ class LineNumberOptionsMapperTest : VimTestCase() {
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
|
||||
// View | Active Editor | Show Line Numbers. There is no UI for line numeration type
|
||||
fixture.editor.settings.isLineNumbersShown = true
|
||||
fixture.editor.settings.lineNumerationType = LineNumerationType.HYBRID
|
||||
assertCommandOutput("set number?", " number")
|
||||
assertCommandOutput("set relativenumber?", " relativenumber")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isLineNumbersShown = true
|
||||
fixture.editor.settings.lineNumerationType = LineNumerationType.HYBRID
|
||||
assertCommandOutput("set number?", " number")
|
||||
assertCommandOutput("set relativenumber?", " relativenumber")
|
||||
|
||||
fixture.editor.settings.lineNumerationType = LineNumerationType.ABSOLUTE
|
||||
assertCommandOutput("set number?", " number")
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
fixture.editor.settings.lineNumerationType = LineNumerationType.ABSOLUTE
|
||||
assertCommandOutput("set number?", " number")
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
|
||||
fixture.editor.settings.lineNumerationType = LineNumerationType.RELATIVE
|
||||
assertCommandOutput("set number?", "nonumber")
|
||||
assertCommandOutput("set relativenumber?", " relativenumber")
|
||||
fixture.editor.settings.lineNumerationType = LineNumerationType.RELATIVE
|
||||
assertCommandOutput("set number?", "nonumber")
|
||||
assertCommandOutput("set relativenumber?", " relativenumber")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test local 'number' and 'relativenumber' options report local intellij settings if set via IDE`() {
|
||||
fixture.editor.settings.isLineNumbersShown = false
|
||||
assertCommandOutput("setlocal number?", "nonumber")
|
||||
assertCommandOutput("setlocal relativenumber?", "norelativenumber")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isLineNumbersShown = false
|
||||
assertCommandOutput("setlocal number?", "nonumber")
|
||||
assertCommandOutput("setlocal relativenumber?", "norelativenumber")
|
||||
|
||||
// View | Active Editor | Show Line Numbers. There is no UI for line numeration type
|
||||
fixture.editor.settings.isLineNumbersShown = true
|
||||
fixture.editor.settings.lineNumerationType = LineNumerationType.HYBRID
|
||||
assertCommandOutput("setlocal number?", " number")
|
||||
assertCommandOutput("setlocal relativenumber?", " relativenumber")
|
||||
// View | Active Editor | Show Line Numbers. There is no UI for line numeration type
|
||||
fixture.editor.settings.isLineNumbersShown = true
|
||||
fixture.editor.settings.lineNumerationType = LineNumerationType.HYBRID
|
||||
assertCommandOutput("setlocal number?", " number")
|
||||
assertCommandOutput("setlocal relativenumber?", " relativenumber")
|
||||
|
||||
fixture.editor.settings.lineNumerationType = LineNumerationType.ABSOLUTE
|
||||
assertCommandOutput("setlocal number?", " number")
|
||||
assertCommandOutput("setlocal relativenumber?", "norelativenumber")
|
||||
fixture.editor.settings.lineNumerationType = LineNumerationType.ABSOLUTE
|
||||
assertCommandOutput("setlocal number?", " number")
|
||||
assertCommandOutput("setlocal relativenumber?", "norelativenumber")
|
||||
|
||||
fixture.editor.settings.lineNumerationType = LineNumerationType.RELATIVE
|
||||
assertCommandOutput("setlocal number?", "nonumber")
|
||||
assertCommandOutput("setlocal relativenumber?", " relativenumber")
|
||||
fixture.editor.settings.lineNumerationType = LineNumerationType.RELATIVE
|
||||
assertCommandOutput("setlocal number?", "nonumber")
|
||||
assertCommandOutput("setlocal relativenumber?", " relativenumber")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -234,8 +245,10 @@ class LineNumberOptionsMapperTest : VimTestCase() {
|
||||
fun `test setting IDE value is treated like setlocal`() {
|
||||
// If we use `:set`, it updates the local and per-window global values. If we set the value from the IDE, it only
|
||||
// affects the local value
|
||||
fixture.editor.settings.isLineNumbersShown = true
|
||||
fixture.editor.settings.lineNumerationType = LineNumerationType.HYBRID
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isLineNumbersShown = true
|
||||
fixture.editor.settings.lineNumerationType = LineNumerationType.HYBRID
|
||||
}
|
||||
|
||||
assertCommandOutput("setlocal number?", " number")
|
||||
assertCommandOutput("set number?", " number")
|
||||
@ -283,115 +296,129 @@ class LineNumberOptionsMapperTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test setting global whitespace IDE value will update effective Vim value set during plugin startup`() {
|
||||
// Default value is false. Update the global value to something different, but make sure the Vim options are default
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
|
||||
// This is the same value as the global IDE setting. That's ok. We just want to explicitly set the Vim option
|
||||
enterCommand("set number")
|
||||
} finally {
|
||||
injector.optionGroup.endInitVimRc()
|
||||
// This is the same value as the global IDE setting. That's ok. We just want to explicitly set the Vim option
|
||||
enterCommand("set number")
|
||||
} finally {
|
||||
injector.optionGroup.endInitVimRc()
|
||||
}
|
||||
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertCommandOutput("setlocal number?", "nonumber")
|
||||
assertCommandOutput("set number?", "nonumber")
|
||||
assertCommandOutput("setglobal number?", "nonumber")
|
||||
}
|
||||
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertCommandOutput("setlocal number?", "nonumber")
|
||||
assertCommandOutput("set number?", "nonumber")
|
||||
assertCommandOutput("setglobal number?", "nonumber")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test setting global numeration type IDE value will update effective Vim value set during plugin startup`() {
|
||||
// Default value is ABSOLUTE. Update the global value to something different, but make sure the Vim options are default
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.RELATIVE
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.RELATIVE
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
enterCommand("set relativenumber")
|
||||
} finally {
|
||||
injector.optionGroup.endInitVimRc()
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
enterCommand("set relativenumber")
|
||||
} finally {
|
||||
injector.optionGroup.endInitVimRc()
|
||||
}
|
||||
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.ABSOLUTE
|
||||
assertCommandOutput("setlocal relativenumber?", "norelativenumber")
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
assertCommandOutput("setglobal relativenumber?", "norelativenumber")
|
||||
}
|
||||
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.ABSOLUTE
|
||||
assertCommandOutput("setlocal relativenumber?", "norelativenumber")
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
assertCommandOutput("setglobal relativenumber?", "norelativenumber")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test reset 'number' to default copies current global intellij setting`() {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.ABSOLUTE
|
||||
fixture.editor.settings.isLineNumbersShown = false
|
||||
assertCommandOutput("set number?", "nonumber")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.ABSOLUTE
|
||||
fixture.editor.settings.isLineNumbersShown = false
|
||||
assertCommandOutput("set number?", "nonumber")
|
||||
|
||||
enterCommand("set number&")
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isLineNumbersShown)
|
||||
assertEquals(LineNumerationType.ABSOLUTE, EditorSettingsExternalizable.getInstance().lineNumeration)
|
||||
enterCommand("set number&")
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isLineNumbersShown)
|
||||
assertEquals(LineNumerationType.ABSOLUTE, EditorSettingsExternalizable.getInstance().lineNumeration)
|
||||
|
||||
// Verify that IntelliJ doesn't allow us to "unset" a local editor setting - it's a copy of the default value
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
// Verify that IntelliJ doesn't allow us to "unset" a local editor setting - it's a copy of the default value
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test reset 'relativenumber' to default copies current global intellij setting`() {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.RELATIVE
|
||||
injector.optionGroup.resetAllOptionsForTesting() // So changing the global values does not modify IdeaVim's values
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.RELATIVE
|
||||
injector.optionGroup.resetAllOptionsForTesting() // So changing the global values does not modify IdeaVim's values
|
||||
|
||||
// Value becomes External(true) because the user is explicitly setting it
|
||||
fixture.editor.settings.isLineNumbersShown = false
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
// Value becomes External(true) because the user is explicitly setting it
|
||||
fixture.editor.settings.isLineNumbersShown = false
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
|
||||
enterCommand("set relativenumber&")
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isLineNumbersShown)
|
||||
assertEquals(LineNumerationType.RELATIVE, EditorSettingsExternalizable.getInstance().lineNumeration)
|
||||
enterCommand("set relativenumber&")
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isLineNumbersShown)
|
||||
assertEquals(LineNumerationType.RELATIVE, EditorSettingsExternalizable.getInstance().lineNumeration)
|
||||
|
||||
// Changing the global value should not update local value, because the user has explicitly changed it
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
// Changing the global value should not update local value, because the user has explicitly changed it
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test local reset 'number' to default copies current global intellij setting`() {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.ABSOLUTE
|
||||
fixture.editor.settings.isLineNumbersShown = false
|
||||
assertCommandOutput("set number?", "nonumber")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.ABSOLUTE
|
||||
fixture.editor.settings.isLineNumbersShown = false
|
||||
assertCommandOutput("set number?", "nonumber")
|
||||
|
||||
enterCommand("setlocal number&")
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isLineNumbersShown)
|
||||
assertEquals(LineNumerationType.ABSOLUTE, EditorSettingsExternalizable.getInstance().lineNumeration)
|
||||
enterCommand("setlocal number&")
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isLineNumbersShown)
|
||||
assertEquals(LineNumerationType.ABSOLUTE, EditorSettingsExternalizable.getInstance().lineNumeration)
|
||||
|
||||
// Verify that IntelliJ doesn't allow us to "unset" a local editor setting - it's a copy of the default value
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
// Verify that IntelliJ doesn't allow us to "unset" a local editor setting - it's a copy of the default value
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test reset local 'relativenumber' to default copies current global intellij setting`() {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.RELATIVE
|
||||
injector.optionGroup.resetAllOptionsForTesting() // So changing the global values does not modify IdeaVim's values
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.RELATIVE
|
||||
injector.optionGroup.resetAllOptionsForTesting() // So changing the global values does not modify IdeaVim's values
|
||||
|
||||
// Value becomes External(true) because the user is explicitly setting it
|
||||
fixture.editor.settings.isLineNumbersShown = false
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
// Value becomes External(true) because the user is explicitly setting it
|
||||
fixture.editor.settings.isLineNumbersShown = false
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
|
||||
enterCommand("setlocal relativenumber&")
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isLineNumbersShown)
|
||||
assertEquals(LineNumerationType.RELATIVE, EditorSettingsExternalizable.getInstance().lineNumeration)
|
||||
enterCommand("setlocal relativenumber&")
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isLineNumbersShown)
|
||||
assertEquals(LineNumerationType.RELATIVE, EditorSettingsExternalizable.getInstance().lineNumeration)
|
||||
|
||||
// Changing the global value should not update local value, because the user has explicitly changed it
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
// Changing the global value should not update local value, because the user has explicitly changed it
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertTrue(fixture.editor.settings.isLineNumbersShown)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -405,8 +432,10 @@ class LineNumberOptionsMapperTest : VimTestCase() {
|
||||
assertCommandOutput("set number?", "nonumber")
|
||||
|
||||
// Changing the global setting should update the new editor
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.ABSOLUTE
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.ABSOLUTE
|
||||
}
|
||||
assertCommandOutput("set number?", " number")
|
||||
}
|
||||
|
||||
@ -414,16 +443,18 @@ class LineNumberOptionsMapperTest : VimTestCase() {
|
||||
fun `test open new window without setting 'relativenumber' copies value as not-explicitly set`() {
|
||||
// New window will clone local and global local-to-window options, then apply global to local. This tests that our
|
||||
// handling of per-window "global" values is correct.
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
|
||||
switchToNewFile("bbb.txt", "lorem ipsum")
|
||||
switchToNewFile("bbb.txt", "lorem ipsum")
|
||||
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
|
||||
// Changing the global setting should update the new editor
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.RELATIVE
|
||||
assertCommandOutput("set relativenumber?", " relativenumber")
|
||||
// Changing the global setting should update the new editor
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.RELATIVE
|
||||
assertCommandOutput("set relativenumber?", " relativenumber")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -517,44 +548,48 @@ class LineNumberOptionsMapperTest : VimTestCase() {
|
||||
@Test
|
||||
fun `test setting global whitespace IDE value will update effective Vim value in new window initialised during startup`() {
|
||||
// Default value is false. Update the global value to something different, but make sure the Vim options are default
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = true
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
enterCommand("set number")
|
||||
} finally {
|
||||
injector.optionGroup.endInitVimRc()
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
enterCommand("set number")
|
||||
} finally {
|
||||
injector.optionGroup.endInitVimRc()
|
||||
}
|
||||
|
||||
switchToNewFile("bbb.txt", "lorem ipsum")
|
||||
assertCommandOutput("set number?", " number")
|
||||
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertCommandOutput("setlocal number?", "nonumber")
|
||||
assertCommandOutput("set number?", "nonumber")
|
||||
assertCommandOutput("setglobal number?", "nonumber")
|
||||
}
|
||||
|
||||
switchToNewFile("bbb.txt", "lorem ipsum")
|
||||
assertCommandOutput("set number?", " number")
|
||||
|
||||
EditorSettingsExternalizable.getInstance().isLineNumbersShown = false
|
||||
assertCommandOutput("setlocal number?", "nonumber")
|
||||
assertCommandOutput("set number?", "nonumber")
|
||||
assertCommandOutput("setglobal number?", "nonumber")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test setting global numeration type IDE value will update effective Vim value in new window initialised during startup`() {
|
||||
// Default value is ABSOLUTE. Update the global value to something different, but make sure the Vim options are default
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.RELATIVE
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.RELATIVE
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
enterCommand("set relativenumber")
|
||||
} finally {
|
||||
injector.optionGroup.endInitVimRc()
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
enterCommand("set relativenumber")
|
||||
} finally {
|
||||
injector.optionGroup.endInitVimRc()
|
||||
}
|
||||
|
||||
switchToNewFile("bbb.txt", "lorem ipsum")
|
||||
assertCommandOutput("set relativenumber?", " relativenumber")
|
||||
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.ABSOLUTE
|
||||
assertCommandOutput("setlocal relativenumber?", "norelativenumber")
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
assertCommandOutput("setglobal relativenumber?", "norelativenumber")
|
||||
}
|
||||
|
||||
switchToNewFile("bbb.txt", "lorem ipsum")
|
||||
assertCommandOutput("set relativenumber?", " relativenumber")
|
||||
|
||||
EditorSettingsExternalizable.getInstance().lineNumeration = LineNumerationType.ABSOLUTE
|
||||
assertCommandOutput("setlocal relativenumber?", "norelativenumber")
|
||||
assertCommandOutput("set relativenumber?", "norelativenumber")
|
||||
assertCommandOutput("setglobal relativenumber?", "norelativenumber")
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.option.overrides
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.group.IjOptions
|
||||
@ -31,7 +32,9 @@ class ListOptionMapperTest : VimTestCase() {
|
||||
@Suppress("SameParameterValue")
|
||||
private fun switchToNewFile(filename: String, content: String) {
|
||||
// This replaces fixture.editor
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
}
|
||||
|
||||
// But our selection changed callback doesn't get called immediately, and that callback will deactivate the ex entry
|
||||
// panel (which causes problems if our next command is `:set`). So type something (`0` is a good no-op) to give time
|
||||
@ -167,7 +170,11 @@ class ListOptionMapperTest : VimTestCase() {
|
||||
fun `test setting global IDE value will update effective Vim value set during plugin startup`() {
|
||||
// Default value is false. Update the global value to something different, but make sure the Vim options are default
|
||||
EditorSettingsExternalizable.getInstance().isWhitespacesShown = true
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
@ -288,7 +295,11 @@ class ListOptionMapperTest : VimTestCase() {
|
||||
fun `test setting global IDE value will update effective Vim value in new window initialised from value set during startup`() {
|
||||
// Default value is false. Update the global value to something different, but make sure the Vim options are default
|
||||
EditorSettingsExternalizable.getInstance().isWhitespacesShown = true
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
injector.optionGroup.resetAllOptionsForTesting()
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.option.overrides
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
|
||||
@ -39,7 +40,9 @@ class ScrollJumpOptionMapperTest : VimTestCase() {
|
||||
@Suppress("SameParameterValue")
|
||||
private fun switchToNewFile(filename: String, content: String) {
|
||||
// This replaces fixture.editor
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
}
|
||||
|
||||
// But our selection changed callback doesn't get called immediately, and that callback will deactivate the ex entry
|
||||
// panel (which causes problems if our next command is `:set`). So type something (`0` is a good no-op) to give time
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.option.overrides
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
|
||||
@ -38,7 +39,9 @@ class ScrollOffOptionMapperTest : VimTestCase() {
|
||||
@Suppress("SameParameterValue")
|
||||
private fun switchToNewFile(filename: String, content: String) {
|
||||
// This replaces fixture.editor
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
}
|
||||
|
||||
// But our selection changed callback doesn't get called immediately, and that callback will deactivate the ex entry
|
||||
// panel (which causes problems if our next command is `:set`). So type something (`0` is a good no-op) to give time
|
||||
@ -160,10 +163,13 @@ class ScrollOffOptionMapperTest : VimTestCase() {
|
||||
fun `test setting global IDE value will update IdeaVim value`() {
|
||||
enterCommand("set scrolloff=10")
|
||||
|
||||
EditorSettingsExternalizable.getInstance().verticalScrollOffset = 20
|
||||
assertCommandOutput("set scrolloff?", " scrolloff=20")
|
||||
assertCommandOutput("setlocal scrolloff?", " scrolloff=-1")
|
||||
assertCommandOutput("setglobal scrolloff?", " scrolloff=20")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().verticalScrollOffset = 20
|
||||
|
||||
assertCommandOutput("set scrolloff?", " scrolloff=20")
|
||||
assertCommandOutput("setlocal scrolloff?", " scrolloff=-1")
|
||||
assertCommandOutput("setglobal scrolloff?", " scrolloff=20")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -199,16 +205,18 @@ class ScrollOffOptionMapperTest : VimTestCase() {
|
||||
assertCommandOutput("set scrolloff?", " scrolloff=20")
|
||||
|
||||
// Changing the global IntelliJ setting syncs with the global Vim value
|
||||
EditorSettingsExternalizable.getInstance().verticalScrollOffset = 10
|
||||
assertCommandOutput("set scrolloff?", " scrolloff=10")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().verticalScrollOffset = 10
|
||||
assertCommandOutput("set scrolloff?", " scrolloff=10")
|
||||
|
||||
// We don't support externally changing the local editor setting
|
||||
enterCommand("setlocal scrolloff=30")
|
||||
assertCommandOutput("set scrolloff?", " scrolloff=30")
|
||||
assertCommandOutput("setlocal scrolloff?", " scrolloff=30")
|
||||
assertCommandOutput("setglobal scrolloff?", " scrolloff=10")
|
||||
assertEquals(10, EditorSettingsExternalizable.getInstance().verticalScrollOffset)
|
||||
assertEquals(0, fixture.editor.settings.verticalScrollOffset)
|
||||
// We don't support externally changing the local editor setting
|
||||
enterCommand("setlocal scrolloff=30")
|
||||
assertCommandOutput("set scrolloff?", " scrolloff=30")
|
||||
assertCommandOutput("setlocal scrolloff?", " scrolloff=30")
|
||||
assertCommandOutput("setglobal scrolloff?", " scrolloff=10")
|
||||
assertEquals(10, EditorSettingsExternalizable.getInstance().verticalScrollOffset)
|
||||
assertEquals(0, fixture.editor.settings.verticalScrollOffset)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -270,29 +278,31 @@ class ScrollOffOptionMapperTest : VimTestCase() {
|
||||
|
||||
@Test
|
||||
fun `test reset 'scrolloff' to default value resets global value to intellij global value for all editors`() {
|
||||
EditorSettingsExternalizable.getInstance().verticalScrollOffset = 20
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().verticalScrollOffset = 20
|
||||
|
||||
val firstEditor = fixture.editor
|
||||
val firstEditor = fixture.editor
|
||||
|
||||
switchToNewFile("bbb.txt", "lorem ipsum")
|
||||
switchToNewFile("bbb.txt", "lorem ipsum")
|
||||
|
||||
enterCommand("set scrolloff=10")
|
||||
assertCommandOutput("set scrolloff?", " scrolloff=10")
|
||||
assertCommandOutput("setglobal scrolloff?", " scrolloff=10")
|
||||
assertCommandOutput("setlocal scrolloff?", " scrolloff=-1")
|
||||
assertEquals(10, injector.options(firstEditor.vim).scrolloff) // Equivalent to `set scrolloff?`
|
||||
enterCommand("set scrolloff=10")
|
||||
assertCommandOutput("set scrolloff?", " scrolloff=10")
|
||||
assertCommandOutput("setglobal scrolloff?", " scrolloff=10")
|
||||
assertCommandOutput("setlocal scrolloff?", " scrolloff=-1")
|
||||
assertEquals(10, injector.options(firstEditor.vim).scrolloff) // Equivalent to `set scrolloff?`
|
||||
|
||||
enterCommand("set scrolloff&")
|
||||
assertCommandOutput("set scrolloff?", " scrolloff=20")
|
||||
assertCommandOutput("setglobal scrolloff?", " scrolloff=20")
|
||||
assertCommandOutput("setlocal scrolloff?", " scrolloff=-1")
|
||||
assertEquals(20, injector.options(firstEditor.vim).scrolloff) // Equivalent to `set scrolloff?`
|
||||
enterCommand("set scrolloff&")
|
||||
assertCommandOutput("set scrolloff?", " scrolloff=20")
|
||||
assertCommandOutput("setglobal scrolloff?", " scrolloff=20")
|
||||
assertCommandOutput("setlocal scrolloff?", " scrolloff=-1")
|
||||
assertEquals(20, injector.options(firstEditor.vim).scrolloff) // Equivalent to `set scrolloff?`
|
||||
|
||||
EditorSettingsExternalizable.getInstance().verticalScrollOffset = 15
|
||||
assertCommandOutput("set scrolloff?", " scrolloff=15")
|
||||
assertCommandOutput("setglobal scrolloff?", " scrolloff=15")
|
||||
assertCommandOutput("setlocal scrolloff?", " scrolloff=-1")
|
||||
assertEquals(15, injector.options(firstEditor.vim).scrolloff) // Equivalent to `set scrolloff?`
|
||||
EditorSettingsExternalizable.getInstance().verticalScrollOffset = 15
|
||||
assertCommandOutput("set scrolloff?", " scrolloff=15")
|
||||
assertCommandOutput("setglobal scrolloff?", " scrolloff=15")
|
||||
assertCommandOutput("setlocal scrolloff?", " scrolloff=-1")
|
||||
assertEquals(15, injector.options(firstEditor.vim).scrolloff) // Equivalent to `set scrolloff?`
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.option.overrides
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
|
||||
@ -38,7 +39,9 @@ class SideScrollOffOptionMapperTest : VimTestCase() {
|
||||
@Suppress("SameParameterValue")
|
||||
private fun switchToNewFile(filename: String, content: String) {
|
||||
// This replaces fixture.editor
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
}
|
||||
|
||||
// But our selection changed callback doesn't get called immediately, and that callback will deactivate the ex entry
|
||||
// panel (which causes problems if our next command is `:set`). So type something (`0` is a good no-op) to give time
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.option.overrides
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
|
||||
@ -39,7 +40,9 @@ class SideScrollOptionMapperTest : VimTestCase() {
|
||||
@Suppress("SameParameterValue")
|
||||
private fun switchToNewFile(filename: String, content: String) {
|
||||
// This replaces fixture.editor
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
}
|
||||
|
||||
// But our selection changed callback doesn't get called immediately, and that callback will deactivate the ex entry
|
||||
// panel (which causes problems if our next command is `:set`). So type something (`0` is a good no-op) to give time
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.option.overrides
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.ComponentManagerEx
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
@ -50,7 +51,9 @@ class WrapOptionMapperTest : VimTestCase() {
|
||||
@Suppress("SameParameterValue")
|
||||
private fun switchToNewFile(filename: String, content: String) {
|
||||
// This replaces fixture.editor
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.openFileInEditor(fixture.createFile(filename, content))
|
||||
}
|
||||
|
||||
// But our selection changed callback doesn't get called immediately, and that callback will deactivate the ex entry
|
||||
// panel (which causes problems if our next command is `:set`). So type something (`0` is a good no-op) to give time
|
||||
@ -72,38 +75,46 @@ class WrapOptionMapperTest : VimTestCase() {
|
||||
|
||||
@Test
|
||||
fun `test 'wrap' option reports current global intellij setting if not explicitly set`() {
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
assertCommandOutput("set wrap?", "nowrap")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
assertCommandOutput("set wrap?", "nowrap")
|
||||
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = true
|
||||
assertCommandOutput("set wrap?", " wrap")
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = true
|
||||
assertCommandOutput("set wrap?", " wrap")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test local 'wrap' option reports current global intellij setting if not explicitly set`() {
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
assertCommandOutput("setlocal wrap?", "nowrap")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
assertCommandOutput("setlocal wrap?", "nowrap")
|
||||
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = true
|
||||
assertCommandOutput("setlocal wrap?", " wrap")
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = true
|
||||
assertCommandOutput("setlocal wrap?", " wrap")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test 'wrap' option reports local intellij setting if set via IDE`() {
|
||||
fixture.editor.settings.isUseSoftWraps = true
|
||||
assertCommandOutput("set wrap?", " wrap")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isUseSoftWraps = true
|
||||
assertCommandOutput("set wrap?", " wrap")
|
||||
|
||||
fixture.editor.settings.isUseSoftWraps = false
|
||||
assertCommandOutput("set wrap?", "nowrap")
|
||||
fixture.editor.settings.isUseSoftWraps = false
|
||||
assertCommandOutput("set wrap?", "nowrap")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test local 'wrap' option reports local intellij setting if set via IDE`() {
|
||||
fixture.editor.settings.isUseSoftWraps = true
|
||||
assertCommandOutput("setlocal wrap?", " wrap")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isUseSoftWraps = true
|
||||
assertCommandOutput("setlocal wrap?", " wrap")
|
||||
|
||||
fixture.editor.settings.isUseSoftWraps = false
|
||||
assertCommandOutput("setlocal wrap?", "nowrap")
|
||||
fixture.editor.settings.isUseSoftWraps = false
|
||||
assertCommandOutput("setlocal wrap?", "nowrap")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -132,13 +143,15 @@ class WrapOptionMapperTest : VimTestCase() {
|
||||
|
||||
@Test
|
||||
fun `test setglobal 'wrap' option affects IdeaVim global value only`() {
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
assertCommandOutput("setglobal wrap?", " wrap") // Default for IdeaVim option is true
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
assertCommandOutput("setglobal wrap?", " wrap") // Default for IdeaVim option is true
|
||||
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = true
|
||||
enterCommand("setglobal nowrap")
|
||||
assertCommandOutput("setglobal wrap?", "nowrap")
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isUseSoftWraps)
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = true
|
||||
enterCommand("setglobal nowrap")
|
||||
assertCommandOutput("setglobal wrap?", "nowrap")
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isUseSoftWraps)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -152,10 +165,12 @@ class WrapOptionMapperTest : VimTestCase() {
|
||||
fun `test setting local IDE value is treated like setlocal`() {
|
||||
// If we use `:set`, it updates the local and per-window global values. If we set the value from the IDE, it only
|
||||
// affects the local value
|
||||
fixture.editor.settings.isUseSoftWraps = false
|
||||
assertCommandOutput("setlocal wrap?", "nowrap")
|
||||
assertCommandOutput("set wrap?", "nowrap")
|
||||
assertCommandOutput("setglobal wrap?", " wrap")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isUseSoftWraps = false
|
||||
assertCommandOutput("setlocal wrap?", "nowrap")
|
||||
assertCommandOutput("set wrap?", "nowrap")
|
||||
assertCommandOutput("setglobal wrap?", " wrap")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -175,19 +190,21 @@ class WrapOptionMapperTest : VimTestCase() {
|
||||
|
||||
@Test
|
||||
fun `test setting global IDE value will update effective Vim value set during plugin startup`() {
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
enterCommand("set nowrap")
|
||||
} finally {
|
||||
injector.optionGroup.endInitVimRc()
|
||||
}
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
enterCommand("set nowrap")
|
||||
} finally {
|
||||
injector.optionGroup.endInitVimRc()
|
||||
}
|
||||
|
||||
// Default is true, so reset it to false, then set back to true
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = true
|
||||
assertCommandOutput("setlocal wrap?", " wrap")
|
||||
assertCommandOutput("set wrap?", " wrap")
|
||||
assertCommandOutput("setglobal wrap?", " wrap")
|
||||
// Default is true, so reset it to false, then set back to true
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = true
|
||||
assertCommandOutput("setlocal wrap?", " wrap")
|
||||
assertCommandOutput("set wrap?", " wrap")
|
||||
assertCommandOutput("setglobal wrap?", " wrap")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -204,46 +221,52 @@ class WrapOptionMapperTest : VimTestCase() {
|
||||
|
||||
@Test
|
||||
fun `test reset 'wrap' to default copies current global intellij setting`() {
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = true
|
||||
fixture.editor.settings.isUseSoftWraps = false
|
||||
assertCommandOutput("set wrap?", "nowrap")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = true
|
||||
fixture.editor.settings.isUseSoftWraps = false
|
||||
assertCommandOutput("set wrap?", "nowrap")
|
||||
|
||||
enterCommand("set wrap&")
|
||||
assertTrue(fixture.editor.settings.isUseSoftWraps)
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isUseSoftWraps)
|
||||
enterCommand("set wrap&")
|
||||
assertTrue(fixture.editor.settings.isUseSoftWraps)
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isUseSoftWraps)
|
||||
|
||||
// Verify that IntelliJ doesn't allow us to "unset" a local editor setting - it's a copy of the default value
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
assertTrue(fixture.editor.settings.isUseSoftWraps)
|
||||
// Verify that IntelliJ doesn't allow us to "unset" a local editor setting - it's a copy of the default value
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
assertTrue(fixture.editor.settings.isUseSoftWraps)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test reset local 'wrap' to default copies current global intellij setting`() {
|
||||
fixture.editor.settings.isUseSoftWraps = false
|
||||
assertCommandOutput("setlocal wrap?", "nowrap")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.settings.isUseSoftWraps = false
|
||||
assertCommandOutput("setlocal wrap?", "nowrap")
|
||||
|
||||
enterCommand("setlocal wrap&")
|
||||
assertTrue(fixture.editor.settings.isUseSoftWraps)
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isUseSoftWraps)
|
||||
enterCommand("setlocal wrap&")
|
||||
assertTrue(fixture.editor.settings.isUseSoftWraps)
|
||||
assertTrue(EditorSettingsExternalizable.getInstance().isUseSoftWraps)
|
||||
|
||||
// Verify that IntelliJ doesn't allow us to "unset" a local editor setting - it's a copy of the default value
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
assertTrue(fixture.editor.settings.isUseSoftWraps)
|
||||
// Verify that IntelliJ doesn't allow us to "unset" a local editor setting - it's a copy of the default value
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
assertTrue(fixture.editor.settings.isUseSoftWraps)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test open new window without setting the option copies value as not-explicitly set`() {
|
||||
// New window will clone local and global local-to-window options, then apply global to local. This tests that our
|
||||
// handling of per-window "global" values is correct.
|
||||
assertCommandOutput("set wrap?", " wrap")
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
assertCommandOutput("set wrap?", " wrap")
|
||||
|
||||
switchToNewFile("bbb.txt", "lorem ipsum")
|
||||
switchToNewFile("bbb.txt", "lorem ipsum")
|
||||
|
||||
assertCommandOutput("set wrap?", " wrap")
|
||||
assertCommandOutput("set wrap?", " wrap")
|
||||
|
||||
// Changing the global setting should update the new editor
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
assertCommandOutput("set wrap?", "nowrap")
|
||||
// Changing the global setting should update the new editor
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
assertCommandOutput("set wrap?", "nowrap")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -292,20 +315,22 @@ class WrapOptionMapperTest : VimTestCase() {
|
||||
|
||||
@Test
|
||||
fun `test setting global IDE value will update effective Vim value in new window initialised from value set during startup`() {
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
enterCommand("set nowrap")
|
||||
} finally {
|
||||
injector.optionGroup.endInitVimRc()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
try {
|
||||
injector.optionGroup.startInitVimRc()
|
||||
enterCommand("set nowrap")
|
||||
} finally {
|
||||
injector.optionGroup.endInitVimRc()
|
||||
}
|
||||
|
||||
switchToNewFile("bbb.txt", "lorem ipsum")
|
||||
assertCommandOutput("set wrap?", "nowrap")
|
||||
|
||||
// Changing the global setting should update the editor, because it was initially set during plugin startup
|
||||
// Default is true, so reset before changing again
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = true
|
||||
assertCommandOutput("set wrap?", " wrap")
|
||||
}
|
||||
|
||||
switchToNewFile("bbb.txt", "lorem ipsum")
|
||||
assertCommandOutput("set wrap?", "nowrap")
|
||||
|
||||
// Changing the global setting should update the editor, because it was initially set during plugin startup
|
||||
// Default is true, so reset before changing again
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = false
|
||||
EditorSettingsExternalizable.getInstance().isUseSoftWraps = true
|
||||
assertCommandOutput("set wrap?", " wrap")
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
package org.jetbrains.plugins.ideavim.regex
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.editor.VisualPosition
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
@ -20,8 +21,12 @@ import kotlin.test.assertEquals
|
||||
|
||||
class VimRegexEngineTest : VimTestCase() {
|
||||
private fun findAll(pattern: String): List<TextRange> {
|
||||
val regex = VimRegex(pattern)
|
||||
return regex.findAll(fixture.editor.vim).map { it.range }
|
||||
var result: List<TextRange>? = null
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
val regex = VimRegex(pattern)
|
||||
result = regex.findAll(fixture.editor.vim).map { it.range }
|
||||
}
|
||||
return result!!
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -79,11 +84,13 @@ class VimRegexEngineTest : VimTestCase() {
|
||||
configureByText("Lor${c}em ${c}Ipsum")
|
||||
val editor = fixture.editor.vim
|
||||
val mark = VimMark.create('m', 0, 0, editor.getPath(), editor.extractProtocol())!!
|
||||
val secondCaret = editor.carets().maxByOrNull { it.offset }!!
|
||||
secondCaret.markStorage.setMark(mark)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
val secondCaret = editor.carets().maxByOrNull { it.offset }!!
|
||||
secondCaret.markStorage.setMark(mark)
|
||||
|
||||
val result = findAll("\\%>'m\\%#.")
|
||||
assertEquals(result, listOf(TextRange(6, 7)))
|
||||
val result = findAll("\\%>'m\\%#.")
|
||||
assertEquals(result, listOf(TextRange(6, 7)))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -141,15 +148,17 @@ class VimRegexEngineTest : VimTestCase() {
|
||||
|
||||
val caretModel = fixture.editor.caretModel
|
||||
typeText("v") // a workaround to trigger visual mode
|
||||
caretModel.addCaret(VisualPosition(0, 2))
|
||||
val caret = caretModel.getCaretAt(VisualPosition(0, 2))!!
|
||||
caret.setSelection(0, 5)
|
||||
caretModel.addCaret(VisualPosition(0, 0))
|
||||
caretModel.addCaret(VisualPosition(0, 1))
|
||||
caretModel.addCaret(VisualPosition(0, 3))
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
caretModel.addCaret(VisualPosition(0, 2))
|
||||
val caret = caretModel.getCaretAt(VisualPosition(0, 2))!!
|
||||
caret.setSelection(0, 5)
|
||||
caretModel.addCaret(VisualPosition(0, 0))
|
||||
caretModel.addCaret(VisualPosition(0, 1))
|
||||
caretModel.addCaret(VisualPosition(0, 3))
|
||||
|
||||
val result = findAll("\\%V.\\{-}\\%#.")
|
||||
assertEquals(result, listOf(TextRange(0, 3)))
|
||||
val result = findAll("\\%V.\\{-}\\%#.")
|
||||
assertEquals(result, listOf(TextRange(0, 3)))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -47,7 +47,6 @@ import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
|
||||
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
|
||||
import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl
|
||||
import com.intellij.testFramework.junit5.RunInEdt
|
||||
import com.intellij.util.ui.EmptyClipboardOwner
|
||||
import com.maddyhome.idea.vim.KeyHandler
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
@ -78,7 +77,6 @@ import com.maddyhome.idea.vim.key.MappingOwner
|
||||
import com.maddyhome.idea.vim.key.ToKeysMappingInfo
|
||||
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
|
||||
import com.maddyhome.idea.vim.listener.VimListenerManager
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.newapi.globalIjOptions
|
||||
import com.maddyhome.idea.vim.newapi.ijOptions
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
@ -113,31 +111,8 @@ 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 [IdeaVimTestCase]
|
||||
* 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 IdeaVimTestCase instead",
|
||||
replaceWith = ReplaceWith("IdeaVimTestCase", "org.jetbrains.plugins.ideavim.IdeaVimTestCase")
|
||||
)
|
||||
abstract class VimTestCase : IdeaVimTestCase() {
|
||||
object Checks {
|
||||
var caretShape: Boolean = true
|
||||
@ -245,7 +220,9 @@ abstract class IdeaVimTestCase {
|
||||
|
||||
private fun setDefaultIntelliJSettings(editor: Editor) {
|
||||
// These settings don't have a global setting...
|
||||
editor.settings.isCaretRowShown = IjOptions.cursorline.defaultValue.asBoolean()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
editor.settings.isCaretRowShown = IjOptions.cursorline.defaultValue.asBoolean()
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun createFixture(factory: IdeaTestFixtureFactory): CodeInsightTestFixture {
|
||||
@ -324,13 +301,17 @@ abstract class IdeaVimTestCase {
|
||||
protected fun setEditorVisibleSize(width: Int, height: Int) {
|
||||
val w = (width * EditorHelper.getPlainSpaceWidthFloat(fixture.editor)).roundToInt()
|
||||
val h = height * fixture.editor.lineHeight
|
||||
EditorTestUtil.setEditorVisibleSizeInPixels(fixture.editor, w, h)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
EditorTestUtil.setEditorVisibleSizeInPixels(fixture.editor, w, h)
|
||||
}
|
||||
}
|
||||
|
||||
protected fun setEditorVirtualSpace() {
|
||||
// Enable virtual space at the bottom of the file and force a layout to pick up the changes
|
||||
fixture.editor.settings.isAdditionalPageAtBottom = true
|
||||
(fixture.editor as EditorEx).scrollPane.viewport.doLayout()
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
// Enable virtual space at the bottom of the file and force a layout to pick up the changes
|
||||
fixture.editor.settings.isAdditionalPageAtBottom = true
|
||||
(fixture.editor as EditorEx).scrollPane.viewport.doLayout()
|
||||
}
|
||||
}
|
||||
|
||||
protected fun configureByText(content: String) = configureByText(PlainTextFileType.INSTANCE, content)
|
||||
@ -340,17 +321,21 @@ abstract class IdeaVimTestCase {
|
||||
|
||||
protected fun configureAndGuard(content: String) {
|
||||
val ranges = extractBrackets(content)
|
||||
for ((start, end) in ranges) {
|
||||
fixture.editor.document.createGuardedBlock(start, end)
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
for ((start, end) in ranges) {
|
||||
fixture.editor.document.createGuardedBlock(start, end)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected fun configureAndFold(content: String, @Suppress("SameParameterValue") placeholder: String) {
|
||||
val ranges = extractBrackets(content)
|
||||
fixture.editor.foldingModel.runBatchFoldingOperation {
|
||||
for ((start, end) in ranges) {
|
||||
val foldRegion = fixture.editor.foldingModel.addFoldRegion(start, end, placeholder)
|
||||
foldRegion?.isExpanded = false
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
fixture.editor.foldingModel.runBatchFoldingOperation {
|
||||
for ((start, end) in ranges) {
|
||||
val foldRegion = fixture.editor.foldingModel.addFoldRegion(start, end, placeholder)
|
||||
foldRegion?.isExpanded = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -462,12 +447,14 @@ abstract class IdeaVimTestCase {
|
||||
assertTopLogicalLine(scrollToLogicalLine)
|
||||
assertPosition(caretLogicalLine, caretLogicalColumn)
|
||||
|
||||
// Belt and braces. Let's make sure that the caret is fully onscreen
|
||||
val bottomLogicalLine = fixture.editor.vim.visualLineToBufferLine(
|
||||
EditorHelper.getVisualLineAtBottomOfScreen(fixture.editor),
|
||||
)
|
||||
assertTrue(bottomLogicalLine >= caretLogicalLine)
|
||||
assertTrue(caretLogicalLine >= scrollToLogicalLine)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
// Belt and braces. Let's make sure that the caret is fully onscreen
|
||||
val bottomLogicalLine = fixture.editor.vim.visualLineToBufferLine(
|
||||
EditorHelper.getVisualLineAtBottomOfScreen(fixture.editor),
|
||||
)
|
||||
assertTrue(bottomLogicalLine >= caretLogicalLine)
|
||||
assertTrue(caretLogicalLine >= scrollToLogicalLine)
|
||||
}
|
||||
}
|
||||
|
||||
protected fun typeText(vararg keys: String) = typeText(keys.flatMap { injector.parser.parseKeys(it) })
|
||||
@ -651,36 +638,46 @@ abstract class IdeaVimTestCase {
|
||||
|
||||
// Use logical rather than visual lines, so we can correctly test handling of collapsed folds and soft wraps
|
||||
fun assertVisibleArea(topLogicalLine: Int, bottomLogicalLine: Int) {
|
||||
assertTopLogicalLine(topLogicalLine)
|
||||
assertBottomLogicalLine(bottomLogicalLine)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
assertTopLogicalLine(topLogicalLine)
|
||||
assertBottomLogicalLine(bottomLogicalLine)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun assertTopLogicalLine(topLogicalLine: Int) {
|
||||
val actualVisualTop = EditorHelper.getVisualLineAtTopOfScreen(fixture.editor)
|
||||
val actualLogicalTop = fixture.editor.vim.visualLineToBufferLine(actualVisualTop)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
val actualVisualTop = EditorHelper.getVisualLineAtTopOfScreen(fixture.editor)
|
||||
val actualLogicalTop = fixture.editor.vim.visualLineToBufferLine(actualVisualTop)
|
||||
|
||||
assertEquals(topLogicalLine, actualLogicalTop, "Top logical lines don't match")
|
||||
assertEquals(topLogicalLine, actualLogicalTop, "Top logical lines don't match")
|
||||
}
|
||||
}
|
||||
|
||||
fun assertBottomLogicalLine(bottomLogicalLine: Int) {
|
||||
val actualVisualBottom = EditorHelper.getVisualLineAtBottomOfScreen(fixture.editor)
|
||||
val actualLogicalBottom = fixture.editor.vim.visualLineToBufferLine(actualVisualBottom)
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
val actualVisualBottom = EditorHelper.getVisualLineAtBottomOfScreen(fixture.editor)
|
||||
val actualLogicalBottom = fixture.editor.vim.visualLineToBufferLine(actualVisualBottom)
|
||||
|
||||
assertEquals(bottomLogicalLine, actualLogicalBottom, "Bottom logical lines don't match")
|
||||
assertEquals(bottomLogicalLine, actualLogicalBottom, "Bottom logical lines don't match")
|
||||
}
|
||||
}
|
||||
|
||||
fun assertVisibleLineBounds(logicalLine: Int, leftLogicalColumn: Int, rightLogicalColumn: Int) {
|
||||
val visualLine = IjVimEditor(fixture.editor).bufferLineToVisualLine(logicalLine)
|
||||
val actualLeftVisualColumn = EditorHelper.getVisualColumnAtLeftOfDisplay(fixture.editor, visualLine)
|
||||
val actualLeftLogicalColumn =
|
||||
fixture.editor.visualToLogicalPosition(VisualPosition(visualLine, actualLeftVisualColumn)).column
|
||||
val actualRightVisualColumn = EditorHelper.getVisualColumnAtRightOfDisplay(fixture.editor, visualLine)
|
||||
val actualRightLogicalColumn =
|
||||
fixture.editor.visualToLogicalPosition(VisualPosition(visualLine, actualRightVisualColumn)).column
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
val visualLine = fixture.editor.vim.bufferLineToVisualLine(logicalLine)
|
||||
val actualLeftVisualColumn = EditorHelper.getVisualColumnAtLeftOfDisplay(fixture.editor, visualLine)
|
||||
val actualLeftLogicalColumn =
|
||||
fixture.editor.visualToLogicalPosition(VisualPosition(visualLine, actualLeftVisualColumn)).column
|
||||
val actualRightVisualColumn = EditorHelper.getVisualColumnAtRightOfDisplay(fixture.editor, visualLine)
|
||||
val actualRightLogicalColumn =
|
||||
fixture.editor.visualToLogicalPosition(VisualPosition(visualLine, actualRightVisualColumn)).column
|
||||
|
||||
val expected = ScreenBounds(leftLogicalColumn, rightLogicalColumn)
|
||||
val actual = ScreenBounds(actualLeftLogicalColumn, actualRightLogicalColumn)
|
||||
assertEquals(expected, actual)
|
||||
val expected = ScreenBounds(leftLogicalColumn, rightLogicalColumn)
|
||||
val actual = ScreenBounds(actualLeftLogicalColumn, actualRightLogicalColumn)
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
fun assertLineCount(expected: Int) {
|
||||
@ -953,8 +950,12 @@ abstract class IdeaVimTestCase {
|
||||
relatesToPrecedingText: Boolean,
|
||||
@Suppress("SameParameterValue") widthInColumns: Int,
|
||||
): Inlay<*> {
|
||||
val widthInPixels = (EditorHelper.getPlainSpaceWidthFloat(fixture.editor) * widthInColumns).roundToInt()
|
||||
return EditorTestUtil.addInlay(fixture.editor, offset, relatesToPrecedingText, widthInPixels)
|
||||
var inlay: Inlay<*>? = null
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
val widthInPixels = (EditorHelper.getPlainSpaceWidthFloat(fixture.editor) * widthInColumns).roundToInt()
|
||||
inlay = EditorTestUtil.addInlay(fixture.editor, offset, relatesToPrecedingText, widthInPixels)
|
||||
}
|
||||
return inlay!!
|
||||
}
|
||||
|
||||
// As for inline inlays, height is specified as a multiplier of line height, as we can't guarantee the same line
|
||||
@ -969,7 +970,11 @@ abstract class IdeaVimTestCase {
|
||||
val widthInColumns = 10 // Arbitrary width. We don't care.
|
||||
val widthInPixels = (EditorHelper.getPlainSpaceWidthFloat(fixture.editor) * widthInColumns).roundToInt()
|
||||
val heightInPixels = fixture.editor.lineHeight * heightInRows
|
||||
return EditorTestUtil.addBlockInlay(fixture.editor, offset, false, showAbove, widthInPixels, heightInPixels)
|
||||
var inlay: Inlay<*>? = null
|
||||
ApplicationManager.getApplication().invokeAndWait {
|
||||
inlay = EditorTestUtil.addBlockInlay(fixture.editor, offset, false, showAbove, widthInPixels, heightInPixels)
|
||||
}
|
||||
return inlay!!
|
||||
}
|
||||
|
||||
// Disable or enable checks for the particular test
|
||||
|
@ -10,6 +10,7 @@ package com.maddyhome.idea.vim.api
|
||||
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.common.VimCopiedText
|
||||
import com.maddyhome.idea.vim.helper.RWLockLabel
|
||||
import java.awt.datatransfer.Transferable
|
||||
|
||||
/**
|
||||
@ -50,6 +51,7 @@ interface VimClipboardManager {
|
||||
|
||||
fun dumbCopiedText(text: String): VimCopiedText // TODO this method is NOT preffered, it does not collect transferableData
|
||||
|
||||
@RWLockLabel.Readonly
|
||||
fun getTransferableData(vimEditor: VimEditor, textRange: TextRange): List<Any>
|
||||
|
||||
fun preprocessText(
|
||||
|
@ -83,14 +83,16 @@ sealed class Command(
|
||||
if (Flag.SAVE_VISUAL !in argFlags.flags) {
|
||||
// Editor.inBlockSelection is not available, because we're not in Visual mode anymore. Check if the primary caret
|
||||
// currently has a selection and if (when we still in Visual) it was a block selection.
|
||||
if (editor.primaryCaret().hasSelection() && editor.primaryCaret().lastSelectionInfo.selectionType.isBlock) {
|
||||
editor.removeSecondaryCarets()
|
||||
}
|
||||
editor.nativeCarets().forEach {
|
||||
if (it.hasSelection()) {
|
||||
val offset = it.selectionStart
|
||||
it.removeSelection()
|
||||
it.moveToOffset(offset)
|
||||
injector.application.runReadAction {
|
||||
if (editor.primaryCaret().hasSelection() && editor.primaryCaret().lastSelectionInfo.selectionType.isBlock) {
|
||||
editor.removeSecondaryCarets()
|
||||
}
|
||||
editor.nativeCarets().forEach {
|
||||
if (it.hasSelection()) {
|
||||
val offset = it.selectionStart
|
||||
it.removeSelection()
|
||||
it.moveToOffset(offset)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user