mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-03-05 15:32:51 +01:00
Continue cleanup
This commit is contained in:
parent
5f18e99128
commit
0e7b05e360
src/com/maddyhome/idea/vim
action/motion/gn
ex
extension
group/copy
helper
listener
regexp
ui
test/org/jetbrains/plugins/ideavim
@ -28,7 +28,6 @@ import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.handler.TextObjectActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import java.util.*
|
||||
import javax.swing.KeyStroke
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
|
@ -26,7 +26,6 @@ import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.helper.MessageHelper
|
||||
import com.maddyhome.idea.vim.helper.Msg
|
||||
import com.maddyhome.idea.vim.helper.commandState
|
||||
import com.maddyhome.idea.vim.helper.exitVisualMode
|
||||
import com.maddyhome.idea.vim.helper.inVisualMode
|
||||
import com.maddyhome.idea.vim.helper.noneOfEnum
|
||||
|
@ -27,7 +27,8 @@ import com.maddyhome.idea.vim.ex.ExCommand
|
||||
import com.maddyhome.idea.vim.ex.flags
|
||||
|
||||
class FileHandler : CommandHandler.SingleExecution() {
|
||||
override val argFlags = flags(RangeFlag.RANGE_IS_COUNT, ARGUMENT_FORBIDDEN, Access.READ_ONLY)
|
||||
override val argFlags = flags(RangeFlag.RANGE_IS_COUNT, ARGUMENT_FORBIDDEN, Access.READ_ONLY)
|
||||
|
||||
override fun execute(editor: Editor, context: DataContext, cmd: ExCommand): Boolean {
|
||||
val count = cmd.getCount(editor, 0, false)
|
||||
VimPlugin.getFile().displayFileInfo(editor, count > 0)
|
||||
|
@ -283,13 +283,6 @@ class SearchRange(pattern: String, offset: Int, move: Boolean) : Range(offset, m
|
||||
private val logger = logger<SearchRange>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the pattern range
|
||||
*
|
||||
* @param pattern The text of the pattern. Each subpattern must be separated by the nul character (\\u0000)
|
||||
* @param offset The range offset
|
||||
* @param move True if the cursor should be moved
|
||||
*/
|
||||
init {
|
||||
setPattern(pattern)
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ object VimExtensionFacade {
|
||||
}
|
||||
}
|
||||
VimRepeater.Extension.addString(text)
|
||||
return text;
|
||||
return text
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class VimArgTextObjExtension implements VimExtension {
|
||||
}
|
||||
|
||||
int getBracketPrio(char ch) {
|
||||
return Math.max(openBrackets.toString().indexOf(ch), closeBrackets.indexOf(ch));
|
||||
return Math.max(openBrackets.indexOf(ch), closeBrackets.indexOf(ch));
|
||||
}
|
||||
|
||||
char matchingBracket(char ch) {
|
||||
@ -131,7 +131,7 @@ public class VimArgTextObjExtension implements VimExtension {
|
||||
return openBrackets.charAt(idx);
|
||||
} else {
|
||||
assert isOpenBracket(ch);
|
||||
idx = openBrackets.toString().indexOf(ch);
|
||||
idx = openBrackets.indexOf(ch);
|
||||
return closeBrackets.charAt(idx);
|
||||
}
|
||||
}
|
||||
@ -141,7 +141,7 @@ public class VimArgTextObjExtension implements VimExtension {
|
||||
}
|
||||
|
||||
boolean isOpenBracket(final int ch) {
|
||||
return openBrackets.toString().indexOf(ch) != -1;
|
||||
return openBrackets.indexOf(ch) != -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ class VimExchangeExtension: VimExtension {
|
||||
const val EXCHANGE_CLEAR_CMD = "<Plug>(ExchangeClear)"
|
||||
const val EXCHANGE_LINE_CMD = "<Plug>(ExchangeLine)"
|
||||
|
||||
val EXCHANGE_KEY = Key<Exchange>("exchange");
|
||||
val EXCHANGE_KEY = Key<Exchange>("exchange")
|
||||
|
||||
class Exchange(val type: CommandState.SubMode, val start: Mark, val end: Mark, val text: String) {
|
||||
private var myHighlighter: RangeHighlighter? = null
|
||||
|
@ -86,7 +86,7 @@ class VimMultipleCursorsExtension : VimExtension {
|
||||
inner class NextOccurrenceHandler(val whole: Boolean = true) : WriteActionHandler() {
|
||||
override fun executeInWriteAction(editor: Editor, context: DataContext) {
|
||||
val caretModel = editor.caretModel
|
||||
val patternComparator = if (OptionsManager.ignorecase.isSet) String.CASE_INSENSITIVE_ORDER else Comparator(String::compareTo);
|
||||
val patternComparator = if (OptionsManager.ignorecase.isSet) String.CASE_INSENSITIVE_ORDER else Comparator(String::compareTo)
|
||||
|
||||
if (!editor.inVisualMode) {
|
||||
if (caretModel.caretCount > 1) return
|
||||
@ -99,7 +99,7 @@ class VimMultipleCursorsExtension : VimExtension {
|
||||
if (nextOffset == caret.selectionStart) VimPlugin.showMessage("No more matches")
|
||||
} else {
|
||||
val newPositions = arrayListOf<VisualPosition>()
|
||||
val patterns = sortedSetOf<String>(patternComparator)
|
||||
val patterns = sortedSetOf(patternComparator)
|
||||
for (caret in caretModel.allCarets) {
|
||||
val selectedText = caret.selectedText ?: return
|
||||
patterns += selectedText
|
||||
|
@ -67,7 +67,7 @@ class YankGroup {
|
||||
val type = SelectionType.fromCommandFlags(motion.flags)
|
||||
val range = getTextRange(ranges, type)
|
||||
|
||||
if (range.size() == 0) return false;
|
||||
if (range.size() == 0) return false
|
||||
|
||||
val selectionType = if (type == SelectionType.CHARACTER_WISE && range.isMultiple) SelectionType.BLOCK_WISE else type
|
||||
return yankRange(editor, range, selectionType, startOffsets)
|
||||
|
@ -61,7 +61,7 @@ object CharacterHelper {
|
||||
fun isInvisibleControlCharacter(ch: Char): Boolean {
|
||||
val type = Character.getType(ch).toByte()
|
||||
return type == Character.CONTROL || type == Character.FORMAT || type == Character.PRIVATE_USE
|
||||
|| type == Character.SURROGATE || type == Character.UNASSIGNED;
|
||||
|| type == Character.SURROGATE || type == Character.UNASSIGNED
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ -91,4 +91,4 @@ object CharacterHelper {
|
||||
enum class CharacterType {
|
||||
KEYWORD, HIRAGANA, KATAKANA, HALF_WIDTH_KATAKANA, PUNCTUATION, WHITESPACE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -292,8 +292,8 @@ object VimListenerManager {
|
||||
val editor = event.editor
|
||||
val caret = editor.caretModel.primaryCaret
|
||||
SelectionVimListenerSuppressor.unlock {
|
||||
val predictedMode = IdeaSelectionControl.predictMode(editor, VimListenerManager.SelectionSource.MOUSE)
|
||||
IdeaSelectionControl.controlNonVimSelectionChange(editor, VimListenerManager.SelectionSource.MOUSE)
|
||||
val predictedMode = IdeaSelectionControl.predictMode(editor, SelectionSource.MOUSE)
|
||||
IdeaSelectionControl.controlNonVimSelectionChange(editor, SelectionSource.MOUSE)
|
||||
moveCaretOneCharLeftFromSelectionEnd(editor, predictedMode)
|
||||
caret.vimLastColumn = editor.caretModel.visualPosition.column
|
||||
}
|
||||
@ -351,7 +351,7 @@ object VimListenerManager {
|
||||
override fun mousePressed(e: MouseEvent?) {
|
||||
val editor = (e?.component as? EditorComponentImpl)?.editor ?: return
|
||||
if (editor.isIdeaVimDisabledHere) return
|
||||
val predictedMode = IdeaSelectionControl.predictMode(editor, VimListenerManager.SelectionSource.MOUSE)
|
||||
val predictedMode = IdeaSelectionControl.predictMode(editor, SelectionSource.MOUSE)
|
||||
when (e.clickCount) {
|
||||
1 -> {
|
||||
if (!predictedMode.isEndAllowed) {
|
||||
|
@ -28,6 +28,8 @@ import com.maddyhome.idea.vim.helper.Msg;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class RegExp {
|
||||
public static @Nullable reg_extmatch_T re_extmatch_out = null;
|
||||
public static @Nullable reg_extmatch_T re_extmatch_in = null;
|
||||
@ -559,9 +561,7 @@ public class RegExp {
|
||||
}
|
||||
num_complex_braces = 0;
|
||||
regnpar = 1;
|
||||
for (int i = 0; i < had_endbrace.length; i++) {
|
||||
had_endbrace[i] = false;
|
||||
}
|
||||
Arrays.fill(had_endbrace, false);
|
||||
regnzpar = 1;
|
||||
re_has_z = 0;
|
||||
regflags = 0;
|
||||
|
@ -24,7 +24,7 @@ import com.intellij.util.ui.JBInsets
|
||||
import java.awt.Component
|
||||
import java.awt.Insets
|
||||
|
||||
class ExPanelBorder internal constructor() : SideBorder(JBColor.border(), SideBorder.TOP) {
|
||||
class ExPanelBorder internal constructor() : SideBorder(JBColor.border(), TOP) {
|
||||
|
||||
override fun getBorderInsets(component: Component?): Insets {
|
||||
return JBInsets(getThickness() + 2, 0, 2, 2)
|
||||
|
@ -73,7 +73,7 @@ class RegisterActionsTest : VimTestCase() {
|
||||
val after = "I f${c}ound it in a legendary land"
|
||||
var motionRightAction: ActionBeanClass? = null
|
||||
doTest(keys, before, after, CommandState.Mode.COMMAND, CommandState.SubMode.NONE) {
|
||||
motionRightAction = VIM_ACTIONS_EP.extensions().findAny().get();
|
||||
motionRightAction = VIM_ACTIONS_EP.extensions().findAny().get()
|
||||
|
||||
TestCase.assertNotNull(getCommandNode())
|
||||
|
||||
@ -91,4 +91,4 @@ class RegisterActionsTest : VimTestCase() {
|
||||
val node = VimPlugin.getKey().getKeyRoot(MappingMode.NORMAL)[KeyStroke.getKeyStroke('g')] as CommandPartNode
|
||||
return node[KeyStroke.getKeyStroke('T')] as CommandNode?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class YankMotionActionTest : VimTestCase() {
|
||||
where it was settled on some sodden sand
|
||||
hard by the torrent of a mountain pass.
|
||||
""".trimIndent()
|
||||
typeTextInFile(StringHelper.parseKeys("yW"), file)
|
||||
typeTextInFile(parseKeys("yW"), file)
|
||||
val text = VimPlugin.getRegister().lastRegister?.text ?: kotlin.test.fail()
|
||||
|
||||
TestCase.assertEquals("and", text)
|
||||
@ -55,7 +55,7 @@ class YankMotionActionTest : VimTestCase() {
|
||||
configureByText(file)
|
||||
|
||||
val initialOffset = myFixture.editor.caretModel.offset
|
||||
typeText(StringHelper.parseKeys("yy"))
|
||||
typeText(parseKeys("yy"))
|
||||
|
||||
TestCase.assertEquals(initialOffset, myFixture.editor.caretModel.offset)
|
||||
}
|
||||
@ -65,8 +65,8 @@ class YankMotionActionTest : VimTestCase() {
|
||||
OptionsManager.clipboard.set(ClipboardOptionsData.unnamed)
|
||||
|
||||
try {
|
||||
configureByText("I found it in a ${c}legendary land");
|
||||
typeText(parseKeys("yiw"));
|
||||
configureByText("I found it in a ${c}legendary land")
|
||||
typeText(parseKeys("yiw"))
|
||||
|
||||
val starRegister = VimPlugin.getRegister().getRegister('*') ?: kotlin.test.fail("Register * is empty")
|
||||
Assert.assertEquals("legendary", starRegister.text)
|
||||
@ -79,8 +79,8 @@ class YankMotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
fun `test z saved to " register`() {
|
||||
configureByText("I found it in a ${c}legendary land");
|
||||
typeText(parseKeys("\"zyiw"));
|
||||
configureByText("I found it in a ${c}legendary land")
|
||||
typeText(parseKeys("\"zyiw"))
|
||||
|
||||
val starRegister = VimPlugin.getRegister().getRegister('z') ?: kotlin.test.fail("Register z is empty")
|
||||
Assert.assertEquals("legendary", starRegister.text)
|
||||
@ -90,8 +90,8 @@ class YankMotionActionTest : VimTestCase() {
|
||||
}
|
||||
|
||||
fun `test " saved to " register`() {
|
||||
configureByText("I found it in a ${c}legendary land");
|
||||
typeText(parseKeys("\"zyiw"));
|
||||
configureByText("I found it in a ${c}legendary land")
|
||||
typeText(parseKeys("\"zyiw"))
|
||||
|
||||
val quoteRegister = VimPlugin.getRegister().getRegister('"') ?: kotlin.test.fail("Register \" is empty")
|
||||
Assert.assertEquals("legendary", quoteRegister.text)
|
||||
|
@ -259,7 +259,7 @@ class MultipleCaretsTest : VimTestCase() {
|
||||
|
||||
typeText(commandToKeys("sor"))
|
||||
|
||||
val after = "$c" + before.replace("$c", "").split('\n').sorted().joinToString(separator = "\n")
|
||||
val after = c + before.replace(c, "").split('\n').sorted().joinToString(separator = "\n")
|
||||
myFixture.checkResult(after)
|
||||
}
|
||||
|
||||
@ -297,9 +297,9 @@ class MultipleCaretsTest : VimTestCase() {
|
||||
|
||||
typeText(commandToKeys("sor!"))
|
||||
|
||||
val after = "$c" +
|
||||
val after = c +
|
||||
before
|
||||
.replace("$c", "")
|
||||
.replace(c, "")
|
||||
.split('\n')
|
||||
.sortedWith(reverseOrder())
|
||||
.joinToString(separator = "\n")
|
||||
|
@ -28,36 +28,36 @@ class CmdHandlerTest : VimTestCase() {
|
||||
fun `test recursive`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("command Recur1 Recur2"))
|
||||
typeText(commandToKeys("command Recur1 Recur2"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command Recur2 Recur1"))
|
||||
typeText(commandToKeys("command Recur2 Recur1"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("Recur1"))
|
||||
typeText(commandToKeys("Recur1"))
|
||||
assertPluginError(true) // Recursive command should error.
|
||||
}
|
||||
|
||||
fun `test list aliases`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("command"))
|
||||
typeText(commandToKeys("command"))
|
||||
assertPluginError(false)
|
||||
assertExOutput("Name Args Definition\n") // There should not be any aliases.
|
||||
|
||||
typeText(VimTestCase.commandToKeys("command Vs vs"))
|
||||
typeText(commandToKeys("command Vs vs"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command Wq wq"))
|
||||
typeText(commandToKeys("command Wq wq"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command WQ wq"))
|
||||
typeText(commandToKeys("command WQ wq"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command-nargs=* Test1 echo"))
|
||||
typeText(commandToKeys("command-nargs=* Test1 echo"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command-nargs=? Test2 echo"))
|
||||
typeText(commandToKeys("command-nargs=? Test2 echo"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command-nargs=+ Test3 echo"))
|
||||
typeText(commandToKeys("command-nargs=+ Test3 echo"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command-nargs=1 Test4 echo"))
|
||||
typeText(commandToKeys("command-nargs=1 Test4 echo"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command"))
|
||||
typeText(commandToKeys("command"))
|
||||
assertPluginError(false)
|
||||
// The added alias should be listed
|
||||
assertExOutput("""Name Args Definition
|
||||
@ -70,7 +70,7 @@ class CmdHandlerTest : VimTestCase() {
|
||||
|WQ 0 wq
|
||||
""".trimMargin())
|
||||
|
||||
typeText(VimTestCase.commandToKeys("command W"))
|
||||
typeText(commandToKeys("command W"))
|
||||
assertPluginError(false)
|
||||
// The filtered aliases should be listed
|
||||
assertExOutput("""Name Args Definition
|
||||
@ -82,104 +82,104 @@ class CmdHandlerTest : VimTestCase() {
|
||||
fun `test bad alias`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("Xyz"))
|
||||
typeText(commandToKeys("Xyz"))
|
||||
assertPluginError(true)
|
||||
typeText(VimTestCase.commandToKeys("command Xyz yank"))
|
||||
typeText(commandToKeys("command Xyz yank"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("Xyz"))
|
||||
typeText(commandToKeys("Xyz"))
|
||||
assertPluginError(false)
|
||||
}
|
||||
|
||||
fun `test lowercase should fail`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("command lowercase vs"))
|
||||
typeText(commandToKeys("command lowercase vs"))
|
||||
assertPluginError(true)
|
||||
}
|
||||
|
||||
fun `test blacklisted alias should fail`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("command X vs"))
|
||||
typeText(commandToKeys("command X vs"))
|
||||
assertPluginError(true)
|
||||
typeText(VimTestCase.commandToKeys("command Next vs"))
|
||||
typeText(commandToKeys("command Next vs"))
|
||||
assertPluginError(true)
|
||||
typeText(VimTestCase.commandToKeys("command Print vs"))
|
||||
typeText(commandToKeys("command Print vs"))
|
||||
assertPluginError(true)
|
||||
}
|
||||
|
||||
fun `test add an existing alias and overwrite`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("command Existing1 vs"))
|
||||
typeText(commandToKeys("command Existing1 vs"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command Existing1 wq"))
|
||||
typeText(commandToKeys("command Existing1 wq"))
|
||||
assertPluginError(true)
|
||||
typeText(VimTestCase.commandToKeys("command! Existing1 wq"))
|
||||
typeText(commandToKeys("command! Existing1 wq"))
|
||||
assertPluginError(false)
|
||||
}
|
||||
|
||||
fun `test add command with arguments`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("command -nargs=* Error echo <args>"))
|
||||
typeText(commandToKeys("command -nargs=* Error echo <args>"))
|
||||
assertPluginError(false)
|
||||
}
|
||||
|
||||
fun `test add command with arguments short`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("command-nargs=* Error echo <args>"))
|
||||
typeText(commandToKeys("command-nargs=* Error echo <args>"))
|
||||
assertPluginError(false)
|
||||
}
|
||||
|
||||
fun `test add command with arguments even shorter`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("com-nargs=* Error echo <args>"))
|
||||
typeText(commandToKeys("com-nargs=* Error echo <args>"))
|
||||
assertPluginError(false)
|
||||
}
|
||||
|
||||
fun `test add command with various arguments`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("command! -nargs=0 Error echo <args>"))
|
||||
typeText(commandToKeys("command! -nargs=0 Error echo <args>"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command! -nargs=1 Error echo <args>"))
|
||||
typeText(commandToKeys("command! -nargs=1 Error echo <args>"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command! -nargs=* Error echo <args>"))
|
||||
typeText(commandToKeys("command! -nargs=* Error echo <args>"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command! -nargs=? Error echo <args>"))
|
||||
typeText(commandToKeys("command! -nargs=? Error echo <args>"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command! -nargs=+ Error echo <args>"))
|
||||
typeText(commandToKeys("command! -nargs=+ Error echo <args>"))
|
||||
assertPluginError(false)
|
||||
}
|
||||
|
||||
fun `test add command with invalid arguments`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("command! -nargs= Error echo <args>"))
|
||||
typeText(commandToKeys("command! -nargs= Error echo <args>"))
|
||||
assertPluginError(true)
|
||||
typeText(VimTestCase.commandToKeys("command! -nargs=-1 Error echo <args>"))
|
||||
typeText(commandToKeys("command! -nargs=-1 Error echo <args>"))
|
||||
assertPluginError(true)
|
||||
typeText(VimTestCase.commandToKeys("command! -nargs=# Error echo <args>"))
|
||||
typeText(commandToKeys("command! -nargs=# Error echo <args>"))
|
||||
assertPluginError(true)
|
||||
}
|
||||
|
||||
fun `test run command with arguments`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("let test = \"Hello!\""))
|
||||
typeText(commandToKeys("let test = \"Hello!\""))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command! -nargs=1 Error echo <args>"))
|
||||
typeText(commandToKeys("command! -nargs=1 Error echo <args>"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("Error test"))
|
||||
typeText(commandToKeys("Error test"))
|
||||
assertPluginError(false)
|
||||
assertExOutput("Hello!\n")
|
||||
|
||||
typeText(VimTestCase.commandToKeys("command! -nargs=1 Error echo <q-args>"))
|
||||
typeText(commandToKeys("command! -nargs=1 Error echo <q-args>"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("Error test message"))
|
||||
typeText(commandToKeys("Error test message"))
|
||||
assertPluginError(false)
|
||||
assertExOutput("test message\n")
|
||||
}
|
||||
@ -187,11 +187,11 @@ class CmdHandlerTest : VimTestCase() {
|
||||
fun `test run command that creates another command`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("command! -nargs=1 CreateCommand command -nargs=1 <args> <lt>q-args>"))
|
||||
typeText(commandToKeys("command! -nargs=1 CreateCommand command -nargs=1 <args> <lt>q-args>"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("CreateCommand Show echo"))
|
||||
typeText(commandToKeys("CreateCommand Show echo"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("Show test"))
|
||||
typeText(commandToKeys("Show test"))
|
||||
assertPluginError(false)
|
||||
assertExOutput("test\n")
|
||||
}
|
||||
@ -199,8 +199,8 @@ class CmdHandlerTest : VimTestCase() {
|
||||
fun `test run command missing required argument`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("command! -nargs=1 Error echo <q-args>"))
|
||||
typeText(commandToKeys("command! -nargs=1 Error echo <q-args>"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("Error"))
|
||||
typeText(commandToKeys("Error"))
|
||||
}
|
||||
}
|
||||
|
@ -28,17 +28,17 @@ class DelCmdHandlerTest : VimTestCase() {
|
||||
fun `test remove alias`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("command"))
|
||||
typeText(commandToKeys("command"))
|
||||
assertPluginError(false)
|
||||
assertExOutput("Name Args Definition\n") // There should not be any aliases.
|
||||
|
||||
typeText(VimTestCase.commandToKeys("command Vs vs"))
|
||||
typeText(commandToKeys("command Vs vs"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command Wq wq"))
|
||||
typeText(commandToKeys("command Wq wq"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command WQ wq"))
|
||||
typeText(commandToKeys("command WQ wq"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command"))
|
||||
typeText(commandToKeys("command"))
|
||||
assertPluginError(false)
|
||||
// The added alias should be listed
|
||||
assertExOutput("""Name Args Definition
|
||||
@ -47,7 +47,7 @@ class DelCmdHandlerTest : VimTestCase() {
|
||||
|WQ 0 wq
|
||||
""".trimMargin())
|
||||
|
||||
typeText(VimTestCase.commandToKeys("command W"))
|
||||
typeText(commandToKeys("command W"))
|
||||
assertPluginError(false)
|
||||
// The filtered aliases should be listed
|
||||
assertExOutput("""Name Args Definition
|
||||
@ -56,9 +56,9 @@ class DelCmdHandlerTest : VimTestCase() {
|
||||
""".trimMargin())
|
||||
|
||||
// Delete one of the aliases and then list all aliases again.
|
||||
typeText(VimTestCase.commandToKeys("delcommand Wq"))
|
||||
typeText(commandToKeys("delcommand Wq"))
|
||||
assertPluginError(false)
|
||||
typeText(VimTestCase.commandToKeys("command"))
|
||||
typeText(commandToKeys("command"))
|
||||
assertPluginError(false)
|
||||
assertExOutput("""Name Args Definition
|
||||
|Vs 0 vs
|
||||
@ -69,7 +69,7 @@ class DelCmdHandlerTest : VimTestCase() {
|
||||
fun `test remove non-existant alias`() {
|
||||
VimPlugin.getCommand().resetAliases()
|
||||
configureByText("\n")
|
||||
typeText(VimTestCase.commandToKeys("delcommand VS"))
|
||||
typeText(commandToKeys("delcommand VS"))
|
||||
assertPluginError(true)
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ class MarksHandlerTest : VimTestCase() {
|
||||
fun `test list trims and truncates`() {
|
||||
val indent = " ".repeat(100)
|
||||
val text = "Really long line ".repeat(1000)
|
||||
configureByText(indent + "$c" + text)
|
||||
configureByText(indent + c + text)
|
||||
typeText(parseKeys("ma"))
|
||||
enterCommand("marks a")
|
||||
assertExOutput("""mark line col file/text
|
||||
|
@ -40,31 +40,31 @@ class VimTextObjEntireExtensionTest : JavaVimTestCase() {
|
||||
|
||||
// |gu| |ae|
|
||||
fun testLowerCaseEntireBuffer() {
|
||||
doTest(StringHelper.parseKeys("guae"), poem, "<caret>${poemLC}");
|
||||
doTest(StringHelper.parseKeys("guae"), poem, "<caret>${poemLC}")
|
||||
assertMode(CommandState.Mode.COMMAND)
|
||||
assertSelection(null)
|
||||
}
|
||||
|
||||
// |c| |ae|
|
||||
fun testChangeEntireBuffer() {
|
||||
doTest(StringHelper.parseKeys("cae"), poem, "<caret>");
|
||||
assertMode(CommandState.Mode.INSERT);
|
||||
assertSelection(null);
|
||||
doTest(StringHelper.parseKeys("cae"), poem, "<caret>")
|
||||
assertMode(CommandState.Mode.INSERT)
|
||||
assertSelection(null)
|
||||
}
|
||||
|
||||
// |d| |ae|
|
||||
fun testDeleteEntireBuffer() {
|
||||
doTest(StringHelper.parseKeys("dae"), poem, "<caret>");
|
||||
assertMode(CommandState.Mode.COMMAND);
|
||||
assertSelection(null);
|
||||
doTest(StringHelper.parseKeys("dae"), poem, "<caret>")
|
||||
assertMode(CommandState.Mode.COMMAND)
|
||||
assertSelection(null)
|
||||
}
|
||||
|
||||
// |y| |ae|
|
||||
fun testYankEntireBuffer() {
|
||||
doTest(StringHelper.parseKeys("yae"), poem, "<caret>${poemNoCaret}");
|
||||
assertMode(CommandState.Mode.COMMAND);
|
||||
myFixture.checkResult(poemNoCaret);
|
||||
assertSelection(null);
|
||||
doTest(StringHelper.parseKeys("yae"), poem, "<caret>${poemNoCaret}")
|
||||
assertMode(CommandState.Mode.COMMAND)
|
||||
myFixture.checkResult(poemNoCaret)
|
||||
assertSelection(null)
|
||||
}
|
||||
|
||||
|
||||
@ -90,28 +90,28 @@ class VimTextObjEntireExtensionTest : JavaVimTestCase() {
|
||||
fun testChangeEntireBufferIgnoreLeadingTrailing() {
|
||||
doTest(StringHelper.parseKeys("cie"),
|
||||
"\n \n \n${poem}\n \n \n",
|
||||
"\n \n \n<caret>\n\n \n \n"); // additional \n because poem ends with a \n
|
||||
assertMode(CommandState.Mode.INSERT);
|
||||
assertSelection(null);
|
||||
"\n \n \n<caret>\n\n \n \n") // additional \n because poem ends with a \n
|
||||
assertMode(CommandState.Mode.INSERT)
|
||||
assertSelection(null)
|
||||
}
|
||||
|
||||
// |d| |ae|
|
||||
fun testDeleteEntireBufferIgnoreLeadingTrailing() {
|
||||
doTest(StringHelper.parseKeys("die"),
|
||||
"\n \n \n${poem}\n \n \n",
|
||||
"\n \n \n<caret>\n\n \n \n"); // additional \n because poem ends with a \n
|
||||
assertMode(CommandState.Mode.COMMAND);
|
||||
assertSelection(null);
|
||||
"\n \n \n<caret>\n\n \n \n") // additional \n because poem ends with a \n
|
||||
assertMode(CommandState.Mode.COMMAND)
|
||||
assertSelection(null)
|
||||
}
|
||||
|
||||
// |y| |ae|
|
||||
fun testYankEntireBufferIgnoreLeadingTrailing() {
|
||||
doTest(StringHelper.parseKeys("yie"),
|
||||
"\n \n \n${poem}\n \n \n",
|
||||
"\n \n \n<caret>${poemNoCaret}\n \n \n");
|
||||
assertMode(CommandState.Mode.COMMAND);
|
||||
myFixture.checkResult("\n \n \n${poemNoCaret}\n \n \n");
|
||||
assertSelection(null);
|
||||
"\n \n \n<caret>${poemNoCaret}\n \n \n")
|
||||
assertMode(CommandState.Mode.COMMAND)
|
||||
myFixture.checkResult("\n \n \n${poemNoCaret}\n \n \n")
|
||||
assertSelection(null)
|
||||
}
|
||||
|
||||
val poem: String = """Two roads diverged in a yellow wood,
|
||||
|
Loading…
Reference in New Issue
Block a user