1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-08-01 15:59:06 +02:00

Update version of kt lint and reformat files

This commit is contained in:
Alex Plate 2023-03-13 08:49:25 +02:00
parent a0d3cf561b
commit 8210b122bc
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
268 changed files with 3913 additions and 2868 deletions
build.gradle.kts
src
main/java/com/maddyhome/idea/vim
VimProjectService.kt
action
config/migration
extension
group
handler
helper
listener
mark
newapi
regexp
statistic
ui
vimscript
test/java/org/jetbrains/plugins/ideavim

View File

@ -69,7 +69,7 @@ plugins {
id("org.jetbrains.changelog") version "2.0.0"
// ktlint linter - read more: https://github.com/JLLeitschuh/ktlint-gradle
id("org.jlleitschuh.gradle.ktlint") version "10.3.0"
id("org.jlleitschuh.gradle.ktlint") version "11.3.1"
id("org.jetbrains.kotlinx.kover") version "0.6.1"
id("com.dorongold.task-tree") version "2.1.0"
@ -325,7 +325,7 @@ tasks {
org.jetbrains.changelog.Changelog.OutputType.HTML,
)
}
}
},
)
}
}
@ -334,7 +334,7 @@ tasks {
ktlint {
disabledRules.add("no-wildcard-imports")
version.set("0.43.0")
version.set("0.48.2")
}
// --- Tests
@ -780,7 +780,7 @@ fun updateAuthors(uncheckedEmails: Set<String>) {
for (child in contributorsSection.children) {
if (child.children.size > 1) {
existingEmails.add(
child.children[1].children[0].children[2].children[2].getTextInNode(authors).toString()
child.children[1].children[0].children[2].children[2].getTextInNode(authors).toString(),
)
}
}
@ -959,7 +959,7 @@ fun httpClient(): HttpClient {
Json {
prettyPrint = true
isLenient = true
}
},
)
}
}

View File

@ -17,7 +17,6 @@ import com.maddyhome.idea.vim.group.EditorHolderService
@Service
internal class VimProjectService(val project: Project) : Disposable {
override fun dispose() {
// Not sure if this is a best solution
EditorHolderService.getInstance().editor = null
}

View File

@ -31,7 +31,9 @@ internal class VimPluginToggleAction : DumbAwareToggleAction()/*, LightEditCompa
e.presentation.text = if (ActionPlaces.POPUP == e.place) {
if (VimPlugin.isEnabled()) MessageHelper.message("action.VimPluginToggle.enabled") else MessageHelper.message("action.VimPluginToggle.enable")
} else MessageHelper.message("action.VimPluginToggle.text")
} else {
MessageHelper.message("action.VimPluginToggle.text")
}
}
override fun getActionUpdateThread() = ActionUpdateThread.BGT

View File

@ -73,7 +73,7 @@ internal class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatib
KeyHandler.getInstance().handleKey(
editor.vim,
keyStroke,
injector.executionContextManager.onEditor(editor.vim, e.dataContext.vim)
injector.executionContextManager.onEditor(editor.vim, e.dataContext.vim),
)
if (start != null) {
val duration = System.currentTimeMillis() - start
@ -241,7 +241,7 @@ internal class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatib
init {
VimPlugin.getOptionGroup().addListener(
IjOptionConstants.lookupkeys,
{ parsedLookupKeys = parseLookupKeys() }
{ parsedLookupKeys = parseLookupKeys() },
)
}
@ -271,8 +271,8 @@ internal class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatib
0,
InputEvent.CTRL_DOWN_MASK,
InputEvent.SHIFT_DOWN_MASK,
InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK
)
InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK,
),
)
.addAll(
getKeyStrokes(
@ -280,8 +280,8 @@ internal class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatib
0,
InputEvent.CTRL_DOWN_MASK,
InputEvent.SHIFT_DOWN_MASK,
InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK
)
InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK,
),
)
.addAll(
getKeyStrokes(
@ -289,8 +289,8 @@ internal class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatib
0,
InputEvent.CTRL_DOWN_MASK,
InputEvent.SHIFT_DOWN_MASK,
InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK
)
InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK,
),
)
.addAll(
getKeyStrokes(
@ -298,24 +298,24 @@ internal class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatib
0,
InputEvent.CTRL_DOWN_MASK,
InputEvent.SHIFT_DOWN_MASK,
InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK
)
InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK,
),
)
.addAll(
getKeyStrokes(
KeyEvent.VK_PAGE_UP,
0,
InputEvent.SHIFT_DOWN_MASK,
InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK
)
InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK,
),
)
.addAll(
getKeyStrokes(
KeyEvent.VK_PAGE_DOWN,
0,
InputEvent.SHIFT_DOWN_MASK,
InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK
)
InputEvent.CTRL_DOWN_MASK or InputEvent.SHIFT_DOWN_MASK,
),
).build()
private const val ACTION_ID = "VimShortcutKeyAction"

View File

@ -74,9 +74,8 @@ internal class OperatorAction : VimActionHandler.SingleExecution() {
editor: VimEditor,
context: ExecutionContext,
argument: Argument,
operatorArguments: OperatorArguments
operatorArguments: OperatorArguments,
): TextRange? {
// Note that we're using getMotionRange2 in order to avoid normalising the linewise range into line start
// offsets that will be used to set the change marks. This affects things like the location of the caret in the
// Commentary extension
@ -86,9 +85,8 @@ internal class OperatorAction : VimActionHandler.SingleExecution() {
ijEditor.caretModel.primaryCaret,
context.ij,
argument,
operatorArguments
operatorArguments,
)?.normalize()?.let {
// If we're linewise, make sure the end offset isn't just the EOL char
if (argument.motion.isLinewiseMotion() && it.endOffset < editor.fileSize()) {
TextRange(it.startOffset, it.endOffset + 1)

View File

@ -52,7 +52,7 @@ internal class RepeatChangeAction : VimActionHandler.SingleExecution() {
editor.ij.project,
{ lastHandler.execute(editor, context, operatorArguments) },
"Vim " + lastHandler.javaClass.simpleName,
null
null,
)
} else if (!repeatHandler && lastCommand != null) {
if (cmd.rawCount > 0) {

View File

@ -50,7 +50,7 @@ public class DeleteJoinVisualLinesAction : VisualOperatorActionHandler.SingleExe
caret,
range.toVimTextRange(true).normalize(),
false,
operatorArguments
operatorArguments,
)
) {
res = false

View File

@ -50,7 +50,7 @@ public class DeleteJoinVisualLinesSpacesAction : VisualOperatorActionHandler.Sin
caret,
range.toVimTextRange(true).normalize(),
true,
operatorArguments
operatorArguments,
)
) {
res = false

View File

@ -26,14 +26,14 @@ import javax.swing.KeyStroke
internal class VimEditorBackSpace : IdeActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE), ComplicatedKeysAction {
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.CTRL_DOWN_MASK)),
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0))
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0)),
)
override val type: Command.Type = Command.Type.DELETE
}
internal class VimEditorDelete : IdeActionHandler(IdeActions.ACTION_EDITOR_DELETE), ComplicatedKeysAction {
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0))
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)),
)
override val type: Command.Type = Command.Type.DELETE
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_SAVE_STROKE)
@ -42,7 +42,7 @@ internal class VimEditorDelete : IdeActionHandler(IdeActions.ACTION_EDITOR_DELET
internal class VimEditorDown : IdeActionHandler(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN), ComplicatedKeysAction {
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0)),
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_DOWN, 0))
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_DOWN, 0)),
)
override val type: Command.Type = Command.Type.MOTION
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_CLEAR_STROKES)
@ -51,7 +51,7 @@ internal class VimEditorDown : IdeActionHandler(IdeActions.ACTION_EDITOR_MOVE_CA
internal class VimEditorTab : IdeActionHandler(IdeActions.ACTION_EDITOR_TAB), ComplicatedKeysAction {
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.CTRL_DOWN_MASK)),
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0))
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0)),
)
override val type: Command.Type = Command.Type.INSERT
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_SAVE_STROKE)
@ -60,7 +60,7 @@ internal class VimEditorTab : IdeActionHandler(IdeActions.ACTION_EDITOR_TAB), Co
internal class VimEditorUp : IdeActionHandler(IdeActions.ACTION_EDITOR_MOVE_CARET_UP), ComplicatedKeysAction {
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0)),
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_UP, 0))
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_UP, 0)),
)
override val type: Command.Type = Command.Type.MOTION
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_CLEAR_STROKES)

View File

@ -114,8 +114,9 @@ internal class AddBlockInlaysAction : AnAction() {
private fun getCurrentContext(editor: Editor): FontRenderContext {
val editorContext = FontInfo.getFontRenderContext(editor.contentComponent)
return FontRenderContext(
editorContext.transform, AntialiasingType.getKeyForCurrentScope(false),
if (editor is EditorImpl) UISettings.editorFractionalMetricsHint else RenderingHints.VALUE_FRACTIONALMETRICS_OFF
editorContext.transform,
AntialiasingType.getKeyForCurrentScope(false),
if (editor is EditorImpl) UISettings.editorFractionalMetricsHint else RenderingHints.VALUE_FRACTIONALMETRICS_OFF,
)
}

View File

@ -46,7 +46,7 @@ internal class AddInlineInlaysAction : AnAction() {
inlayModel.addInlineElement(
offset,
relatesToPrecedingText,
HintRenderer(if (relatesToPrecedingText) ":$text" else "$text:")
HintRenderer(if (relatesToPrecedingText) ":$text" else "$text:"),
)
// Every 20 chars +/- 5 chars
i += 20 + (random.nextInt(10) - 5)

View File

@ -15,12 +15,12 @@ import com.maddyhome.idea.vim.VimPlugin
// This variable describe migrators and detectors that would be injected during production run
private val productionMigrationComponents = MigrationComponents(
migrators = setOf(
`Version 6 to 7 config migration`
`Version 6 to 7 config migration`,
),
versionDetectors = listOf(
`Detect versions 3, 4, 5, 6`
`Detect versions 3, 4, 5, 6`,
),
currentVersion = VimPlugin.STATE_VERSION
currentVersion = VimPlugin.STATE_VERSION,
)
// Just a collection of migrators and collectors
@ -79,7 +79,9 @@ internal class ApplicationConfigurationMigrator(migrationComponents: MigrationCo
version = if (configMigrator != null) {
configMigrator.versionUp()
configMigrator.toVersion
} else version + 1
} else {
version + 1
}
}
}

View File

@ -39,7 +39,6 @@ internal object `Version 6 to 7 config migration` : ConfigMigrator {
}
fun performMigration(configuration: Element): Pair<Element, Element> {
val (local, shared) = configuration.getChildren("component").partition { it.getAttribute("name").value in local }
val sharedElement = Element("application")

View File

@ -47,7 +47,8 @@ internal object VimExtensionRegistrar : VimExtensionRegistrator {
unregisterExtension(extension)
}
},
false, VimPlugin.getInstance()
false,
VimPlugin.getInstance(),
)
}
@ -70,7 +71,7 @@ internal object VimExtensionRegistrar : VimExtensionRegistrator {
extensionBean.instance.dispose()
}
}
}
},
)
}

View File

@ -127,7 +127,7 @@ internal class CommentaryExtension : VimExtension {
injector.parser.parseKeys("gcu"),
owner,
injector.parser.parseKeys("<Plug>Commentary<Plug>Commentary"),
true
true,
)
// Previous versions of IdeaVim used different mappings to Vim's Commentary. Make sure everything works if someone
@ -192,7 +192,6 @@ internal class CommentaryExtension : VimExtension {
rawCount: Int,
argument: Argument?,
): TextRange? {
val nativeEditor = (editor as IjVimEditor).editor
val file = PsiHelper.getFile(nativeEditor) ?: return null
val lastLine = editor.lineCount()
@ -218,8 +217,9 @@ internal class CommentaryExtension : VimExtension {
val startElement = file.findElementAt(startOffset) ?: return false
var next: PsiElement? = startElement
while (next != null && next.textRange.startOffset <= endOffset) {
if (next !is PsiWhiteSpace && !isComment(next))
if (next !is PsiWhiteSpace && !isComment(next)) {
return false
}
next = PsiTreeUtil.nextLeaf(next, true)
}

View File

@ -154,7 +154,7 @@ internal class VimExchangeExtension : VimExtension {
(ijEditor.getMarkOffset(ex.end) + endAdj).coerceAtMost(ijEditor.fileSize),
HighlighterLayer.SELECTION - 1,
attributes,
hlArea
hlArea,
)
}
@ -200,7 +200,7 @@ internal class VimExchangeExtension : VimExtension {
val vimEditor = editor.vim
injector.markService.setChangeMarks(
vimEditor.primaryCaret(),
TextRange(editor.getMarkOffset(targetExchange.start), editor.getMarkOffset(targetExchange.end) + 1)
TextRange(editor.getMarkOffset(targetExchange.start), editor.getMarkOffset(targetExchange.end) + 1),
)
// do this instead of direct text manipulation to set change marks
setRegister('z', injector.parser.stringToKeys(sourceExchange.text), SelectionType.fromSubMode(sourceExchange.type))
@ -217,16 +217,16 @@ internal class VimExchangeExtension : VimExtension {
primaryCaret.moveToInlayAwareLogicalPosition(
LogicalPosition(
ex1.start.line,
ex1.start.col - horizontalOffset
)
ex1.start.col - horizontalOffset,
),
)
} else if (ex1.end.line - ex1.start.line != ex2.end.line - ex2.start.line) {
val verticalOffset = ex1.end.line - ex2.end.line
primaryCaret.moveToInlayAwareLogicalPosition(
LogicalPosition(
ex1.start.line - verticalOffset,
ex1.start.col
)
ex1.start.col,
),
)
}
}
@ -308,7 +308,6 @@ internal class VimExchangeExtension : VimExtension {
}
private fun getExchange(editor: Editor, isVisual: Boolean, selectionType: SelectionType): Exchange {
// TODO: improve KeyStroke list to sting conversion
fun getRegisterText(reg: Char): String = getRegister(reg)?.map { it.keyChar }?.joinToString("") ?: ""
fun getMarks(isVisual: Boolean): Pair<Mark, Mark> {

View File

@ -111,7 +111,7 @@ internal class VimHighlightedYank : VimExtension, VimYankListener, VimInsertList
val project = editor.project
if (project != null) {
Disposer.register(
VimProjectService.getInstance(project)
VimProjectService.getInstance(project),
) {
this.editor = null
yankHighlighters.clear()
@ -141,7 +141,7 @@ internal class VimHighlightedYank : VimExtension, VimYankListener, VimInsertList
range.endInclusive,
HighlighterLayer.SELECTION,
getHighlightTextAttributes(),
HighlighterTargetArea.EXACT_RANGE
HighlighterTargetArea.EXACT_RANGE,
)
yankHighlighters.add(highlighter)
@ -160,7 +160,8 @@ internal class VimHighlightedYank : VimExtension, VimYankListener, VimInsertList
editor?.markupModel?.removeHighlighter(highlighter) ?: StrictMode.fail("Highlighters without an editor")
}
},
timeout, TimeUnit.MILLISECONDS
timeout,
TimeUnit.MILLISECONDS,
)
}
}
@ -170,7 +171,7 @@ internal class VimHighlightedYank : VimExtension, VimYankListener, VimInsertList
extractUsersHighlightColor(),
editor?.colorsScheme?.getColor(EditorColors.CARET_COLOR),
EffectType.SEARCH_MATCH,
Font.PLAIN
Font.PLAIN,
)
private fun extractUsersHighlightDuration(): Long {
@ -201,7 +202,7 @@ internal class VimHighlightedYank : VimExtension, VimYankListener, VimInsertList
@VimNlsSafe val message = MessageHelper.message(
"highlightedyank.invalid.value.of.0.1",
"g:$variable",
e.message ?: ""
e.message ?: "",
)
VimPlugin.showMessage(message)

View File

@ -111,9 +111,11 @@ internal class Matchit : VimExtension {
Argument(
Command(
count,
matchitAction, Command.Type.MOTION, EnumSet.noneOf(CommandFlags::class.java)
)
)
matchitAction,
Command.Type.MOTION,
EnumSet.noneOf(CommandFlags::class.java),
),
),
)
} else {
editor.sortedCarets().forEach { caret ->
@ -154,7 +156,7 @@ private data class LanguagePatterns(
this.openings + newLanguagePatterns.openings,
this.closings + newLanguagePatterns.closings,
this.reversedOpenings + newLanguagePatterns.reversedOpenings,
this.reversedClosings + newLanguagePatterns.reversedClosings
this.reversedClosings + newLanguagePatterns.reversedClosings,
)
}
@ -178,7 +180,7 @@ private data class LanguagePatterns(
// This particular arrangement relies on our checking if the cursor is on a closing pattern first.
val reversedOpenings = mapOf(
openingPattern to Pair(openingPattern, closingPattern),
middlePattern to Pair(openingAndMiddlePatterns, middlePattern)
middlePattern to Pair(openingAndMiddlePatterns, middlePattern),
)
val reversedClosings = mapOf(middleAndClosingPatterns to Pair(openingAndMiddlePatterns, middleAndClosingPatterns))
@ -199,7 +201,7 @@ private data class MatchitSearchParams(
// If the cursor is not in a comment, then we want to ignore any matches found in comments.
// But if we are in comment, then we only want to match on things in comments. The same goes for quotes.
val skipComments: Boolean,
val skipStrings: Boolean
val skipStrings: Boolean,
)
/**
@ -235,7 +237,7 @@ private object FileTypePatterns {
private val htmlLikeFileTypes = setOf(
"HTML", "XML", "XHTML", "JSP", "JavaScript", "JSX Harmony",
"TypeScript", "TypeScript JSX", "Vue.js", "Handlebars/Mustache",
"Asp", "Razor", "UXML", "Xaml"
"Asp", "Razor", "UXML", "Xaml",
)
private val htmlPatterns = createHtmlPatterns()
@ -375,7 +377,7 @@ private fun findMatchingPair(
caretOffset: Int,
isInOpPending: Boolean,
openings: PatternsTable,
closings: PatternsTable
closings: PatternsTable,
): Int {
// For better performance, we limit our search to the current line. This way we don't have to scan the entire file
// to determine if we're on a pattern or not. The original plugin behaves the same way.

View File

@ -83,7 +83,7 @@ internal class VimMultipleCursorsExtension : VimExtension {
injector.parser.parseKeys(NEXT_OCCURRENCE),
owner,
NextOccurrenceHandler(whole = false),
false
false,
)
putExtensionHandlerMapping(MappingMode.NXO, injector.parser.parseKeys(ALL_WHOLE_OCCURRENCES), owner, AllOccurrencesHandler(), false)
putExtensionHandlerMapping(
@ -91,7 +91,7 @@ internal class VimMultipleCursorsExtension : VimExtension {
injector.parser.parseKeys(ALL_OCCURRENCES),
owner,
AllOccurrencesHandler(whole = false),
false
false,
)
putExtensionHandlerMapping(MappingMode.X, injector.parser.parseKeys(SKIP_OCCURRENCE), owner, SkipOccurrenceHandler(), false)
putExtensionHandlerMapping(MappingMode.X, injector.parser.parseKeys(REMOVE_OCCURRENCE), owner, RemoveOccurrenceHandler(), false)

View File

@ -278,7 +278,8 @@ internal class NerdTree : VimExtension {
registerCommand("j", NerdAction.ToIj("Tree-selectNext"))
registerCommand("k", NerdAction.ToIj("Tree-selectPrevious"))
registerCommand(
"NERDTreeMapActivateNode", "o",
"NERDTreeMapActivateNode",
"o",
NerdAction.Code { project, dataContext, _ ->
val tree = ProjectView.getInstance(project).currentProjectViewPane.tree
@ -293,53 +294,58 @@ internal class NerdTree : VimExtension {
} else {
array.forEach { it.navigate(true) }
}
}
},
)
registerCommand(
"NERDTreeMapPreview", "go",
"NERDTreeMapPreview",
"go",
NerdAction.Code { _, dataContext, _ ->
CommonDataKeys.NAVIGATABLE_ARRAY
.getData(dataContext)
?.filter { it.canNavigateToSource() }
?.forEach { it.navigate(false) }
}
},
)
registerCommand(
"NERDTreeMapOpenInTab", "t",
"NERDTreeMapOpenInTab",
"t",
NerdAction.Code { _, dataContext, _ ->
// FIXME: 22.01.2021 Doesn't work correct
CommonDataKeys.NAVIGATABLE_ARRAY
.getData(dataContext)
?.filter { it.canNavigateToSource() }
?.forEach { it.navigate(true) }
}
},
)
registerCommand(
"NERDTreeMapOpenInTabSilent", "T",
"NERDTreeMapOpenInTabSilent",
"T",
NerdAction.Code { _, dataContext, _ ->
// FIXME: 22.01.2021 Doesn't work correct
CommonDataKeys.NAVIGATABLE_ARRAY
.getData(dataContext)
?.filter { it.canNavigateToSource() }
?.forEach { it.navigate(true) }
}
},
)
// TODO: 21.01.2021 Should option in left split
registerCommand("NERDTreeMapOpenVSplit", "s", NerdAction.ToIj("OpenInRightSplit"))
// TODO: 21.01.2021 Should option in above split
registerCommand(
"NERDTreeMapOpenSplit", "i",
"NERDTreeMapOpenSplit",
"i",
NerdAction.Code { project, _, event ->
val file = event.getData(CommonDataKeys.VIRTUAL_FILE) ?: return@Code
if (file.isDirectory) return@Code
val splitters = FileEditorManagerEx.getInstanceEx(project).splitters
val currentWindow = splitters.currentWindow
currentWindow?.split(SwingConstants.HORIZONTAL, true, file, true)
}
},
)
registerCommand(
"NERDTreeMapPreviewVSplit", "gs",
"NERDTreeMapPreviewVSplit",
"gs",
NerdAction.Code { project, context, event ->
val file = event.getData(CommonDataKeys.VIRTUAL_FILE) ?: return@Code
val splitters = FileEditorManagerEx.getInstanceEx(project).splitters
@ -348,10 +354,11 @@ internal class NerdTree : VimExtension {
// FIXME: 22.01.2021 This solution bouncing a bit
callAction(null, "ActivateProjectToolWindow", context.vim)
}
},
)
registerCommand(
"NERDTreeMapPreviewSplit", "gi",
"NERDTreeMapPreviewSplit",
"gi",
NerdAction.Code { project, context, event ->
val file = event.getData(CommonDataKeys.VIRTUAL_FILE) ?: return@Code
val splitters = FileEditorManagerEx.getInstanceEx(project).splitters
@ -359,30 +366,33 @@ internal class NerdTree : VimExtension {
currentWindow?.split(SwingConstants.HORIZONTAL, true, file, true)
callAction(null, "ActivateProjectToolWindow", context.vim)
}
},
)
registerCommand(
"NERDTreeMapOpenRecursively", "O",
"NERDTreeMapOpenRecursively",
"O",
NerdAction.Code { project, _, _ ->
val tree = ProjectView.getInstance(project).currentProjectViewPane.tree
TreeExpandCollapse.expandAll(tree)
tree.selectionPath?.let {
TreeUtil.scrollToVisible(tree, it, false)
}
}
},
)
registerCommand(
"NERDTreeMapCloseChildren", "X",
"NERDTreeMapCloseChildren",
"X",
NerdAction.Code { project, _, _ ->
val tree = ProjectView.getInstance(project).currentProjectViewPane.tree
TreeExpandCollapse.collapse(tree)
tree.selectionPath?.let {
TreeUtil.scrollToVisible(tree, it, false)
}
}
},
)
registerCommand(
"NERDTreeMapCloseDir", "x",
"NERDTreeMapCloseDir",
"x",
NerdAction.Code { project, _, _ ->
val tree = ProjectView.getInstance(project).currentProjectViewPane.tree
val currentPath = tree.selectionPath ?: return@Code
@ -396,11 +406,12 @@ internal class NerdTree : VimExtension {
TreeUtil.scrollToVisible(tree, parentPath, false)
}
}
}
},
)
registerCommand("NERDTreeMapJumpRoot", "P", NerdAction.ToIj("Tree-selectFirst"))
registerCommand(
"NERDTreeMapJumpParent", "p",
"NERDTreeMapJumpParent",
"p",
NerdAction.Code { project, _, _ ->
val tree = ProjectView.getInstance(project).currentProjectViewPane.tree
val currentPath = tree.selectionPath ?: return@Code
@ -410,10 +421,11 @@ internal class NerdTree : VimExtension {
tree.selectionPath = parentPath
TreeUtil.scrollToVisible(tree, parentPath, false)
}
}
},
)
registerCommand(
"NERDTreeMapJumpFirstChild", "K",
"NERDTreeMapJumpFirstChild",
"K",
NerdAction.Code { project, _, _ ->
val tree = ProjectView.getInstance(project).currentProjectViewPane.tree
val currentPath = tree.selectionPath ?: return@Code
@ -422,10 +434,11 @@ internal class NerdTree : VimExtension {
tree.setSelectionRow(row + 1)
tree.scrollRowToVisible(row + 1)
}
},
)
registerCommand(
"NERDTreeMapJumpLastChild", "J",
"NERDTreeMapJumpLastChild",
"J",
NerdAction.Code { project, _, _ ->
val tree = ProjectView.getInstance(project).currentProjectViewPane.tree
val currentPath = tree.selectionPath ?: return@Code
@ -444,22 +457,22 @@ internal class NerdTree : VimExtension {
tree.setSelectionRow(expectedRow)
tree.scrollRowToVisible(expectedRow)
}
},
)
registerCommand(
"NERDTreeMapJumpNextSibling",
"<C-J>",
NerdAction.ToIj("Tree-selectNextSibling")
NerdAction.ToIj("Tree-selectNextSibling"),
)
registerCommand(
"NERDTreeMapJumpPrevSibling",
"<C-K>",
NerdAction.ToIj("Tree-selectPreviousSibling")
NerdAction.ToIj("Tree-selectPreviousSibling"),
)
registerCommand(
"NERDTreeMapRefresh",
"r",
NerdAction.ToIj("SynchronizeCurrentFile")
NerdAction.ToIj("SynchronizeCurrentFile"),
)
registerCommand("NERDTreeMapRefreshRoot", "R", NerdAction.ToIj("Synchronize"))
registerCommand("NERDTreeMapMenu", "m", NerdAction.ToIj("ShowPopupMenu"))
@ -467,14 +480,14 @@ internal class NerdTree : VimExtension {
registerCommand(
"NERDTreeMapToggleZoom",
"A",
NerdAction.ToIj("MaximizeToolWindow")
NerdAction.ToIj("MaximizeToolWindow"),
)
registerCommand(
"/",
NerdAction.Code { project, _, _ ->
NerdDispatcher.getInstance(project).waitForSearch = true
}
},
)
registerCommand(
@ -484,7 +497,7 @@ internal class NerdTree : VimExtension {
if (instance.waitForSearch) {
instance.waitForSearch = false
}
}
},
)
}
@ -537,7 +550,9 @@ internal class NerdTree : VimExtension {
val res = node.keys.toMutableSet()
res += node.values.map { collectShortcuts(it) }.flatten()
res
} else emptySet()
} else {
emptySet()
}
}
private fun installDispatcher(project: Project) {
@ -545,7 +560,7 @@ internal class NerdTree : VimExtension {
val shortcuts = collectShortcuts(actionsRoot).map { RequiredShortcut(it, MappingOwner.Plugin.get(pluginName)) }
dispatcher.registerCustomShortcutSet(
KeyGroup.toShortcutSet(shortcuts),
(ProjectView.getInstance(project) as ProjectViewImpl).component
(ProjectView.getInstance(project) as ProjectViewImpl).component,
)
}
}

View File

@ -113,10 +113,10 @@ internal class ReplaceWithRegister : VimExtension {
range.startOffset,
range.endOffset - 1,
selectionType,
editor
)
editor,
),
),
selectionType
selectionType,
)
// todo multicaret
doReplace(ijEditor, editor.primaryCaret(), visualSelection)
@ -162,7 +162,7 @@ internal class ReplaceWithRegister : VimExtension {
insertTextBeforeCaret = true,
rawIndent = true,
caretAfterInsertedText = false,
putToLine = -1
putToLine = -1,
)
ClipboardOptionHelper.IdeaputDisabler().use {
VimPlugin.getPut().putText(
@ -171,8 +171,10 @@ internal class ReplaceWithRegister : VimExtension {
putData,
operatorArguments = OperatorArguments(
editor.vimStateMachine?.isOperatorPending ?: false,
0, editor.editorMode, editor.subMode
)
0,
editor.editorMode,
editor.subMode,
),
)
}

View File

@ -213,7 +213,7 @@ internal class VimSurroundExtension : VimExtension {
IjVimEditor(ijEditor),
IjVimCaret(primaryCaret),
range.endOffset + leftSurround.length,
pair.second
pair.second,
)
// Jump back to start
executeNormalWithoutMapping(injector.parser.parseKeys("`["), ijEditor)
@ -249,7 +249,7 @@ internal class VimSurroundExtension : VimExtension {
']' to ("[" to "]"),
'a' to ("<" to ">"),
'>' to ("<" to ">"),
's' to (" " to "")
's' to (" " to ""),
)
private fun getSurroundPair(c: Char): Pair<String, String>? = if (c in SURROUND_PAIRS) {
@ -257,7 +257,9 @@ internal class VimSurroundExtension : VimExtension {
} else if (!c.isLetter()) {
val s = c.toString()
s to s
} else null
} else {
null
}
private fun inputTagPair(editor: Editor): Pair<String, String>? {
val tagInput = inputString(editor, "<", '>')
@ -266,7 +268,9 @@ internal class VimSurroundExtension : VimExtension {
val tagName = matcher.group(1)
val tagAttributes = matcher.group(2)
"<$tagName$tagAttributes>" to "</$tagName>"
} else null
} else {
null
}
}
private fun inputFunctionName(
@ -290,7 +294,9 @@ internal class VimSurroundExtension : VimExtension {
val keyChar = key.keyChar
return if (keyChar == KeyEvent.CHAR_UNDEFINED || keyChar.code == KeyEvent.VK_ESCAPE) {
0.toChar()
} else keyChar
} else {
keyChar
}
}
}
}

View File

@ -51,6 +51,7 @@ internal class IjVimStorageService : VimStorageServiceBase() {
}
private val ijKeys = mutableMapOf<String, Key<out Any?>>()
@Suppress("UNCHECKED_CAST")
private fun <T> getOrCreateIjKey(key: com.maddyhome.idea.vim.api.Key<T>): Key<T> {
val storedIjKey = ijKeys[key.name]

View File

@ -49,8 +49,10 @@ internal class MacroGroup : VimMacroBase() {
val isInternalMacro = potemkinProgress != null
val myPotemkinProgress = potemkinProgress ?: PotemkinProgress(
message("progress.title.macro.execution"), project, null,
message("stop")
message("progress.title.macro.execution"),
project,
null,
message("stop"),
)
if (potemkinProgress == null) potemkinProgress = myPotemkinProgress
@ -59,7 +61,6 @@ internal class MacroGroup : VimMacroBase() {
try {
myPotemkinProgress.text2 = if (isInternalMacro) "Executing internal macro" else ""
val runnable = runnable@{
// Handle one keystroke then queue up the next key
for (i in 0 until total) {
myPotemkinProgress.fraction = (i + 1).toDouble() / total

View File

@ -108,7 +108,7 @@ internal class MotionGroup : VimMotionGroupBase() {
editor: VimEditor,
caret: ImmutableVimCaret,
count: Int,
normalizeToScreen: Boolean
normalizeToScreen: Boolean,
): Int {
return moveCaretToScreenLocation(editor.ij, caret.ij, ScreenLocation.TOP, count - 1, normalizeToScreen)
}
@ -117,7 +117,7 @@ internal class MotionGroup : VimMotionGroupBase() {
editor: VimEditor,
caret: ImmutableVimCaret,
count: Int,
normalizeToScreen: Boolean
normalizeToScreen: Boolean,
): Int {
return moveCaretToScreenLocation(editor.ij, caret.ij, ScreenLocation.BOTTOM, count - 1, normalizeToScreen)
}
@ -212,7 +212,7 @@ internal class MotionGroup : VimMotionGroupBase() {
override fun moveCaretToCurrentDisplayLineStartSkipLeading(
editor: VimEditor,
caret: ImmutableVimCaret
caret: ImmutableVimCaret,
): @Range(from = 0, to = Int.MAX_VALUE.toLong()) Int {
val col = EditorHelper.getVisualColumnAtLeftOfDisplay(editor.ij, caret.getVisualPosition().line)
val bufferLine = caret.getLine().line
@ -222,7 +222,7 @@ internal class MotionGroup : VimMotionGroupBase() {
override fun moveCaretToCurrentDisplayLineEnd(
editor: VimEditor,
caret: ImmutableVimCaret,
allowEnd: Boolean
allowEnd: Boolean,
): Motion {
val col = EditorHelper.getVisualColumnAtRightOfDisplay(editor.ij, caret.getVisualPosition().line)
return moveCaretToColumn(editor, caret, col, allowEnd)
@ -231,7 +231,7 @@ internal class MotionGroup : VimMotionGroupBase() {
override fun moveCaretToLineWithSameColumn(
editor: VimEditor,
line: Int,
caret: ImmutableVimCaret
caret: ImmutableVimCaret,
): @Range(from = 0, to = Int.MAX_VALUE.toLong()) Int {
var c = caret.vimLastColumn
var l = line
@ -249,7 +249,7 @@ internal class MotionGroup : VimMotionGroupBase() {
override fun moveCaretToLineWithStartOfLineOption(
editor: VimEditor,
line: Int,
caret: ImmutableVimCaret
caret: ImmutableVimCaret,
): @Range(from = 0, to = Int.MAX_VALUE.toLong()) Int {
return if (injector.options(editor).isSet(OptionConstants.startofline)) {
moveCaretToLineStartSkipLeading(editor, line)
@ -292,12 +292,12 @@ internal class MotionGroup : VimMotionGroupBase() {
override fun moveCaretToLinePercent(
editor: VimEditor,
caret: ImmutableVimCaret,
count: Int
count: Int,
): @Range(from = 0, to = Int.MAX_VALUE.toLong()) Int {
return moveCaretToLineWithStartOfLineOption(
editor,
editor.normalizeLine((editor.lineCount() * clamp(count, 0, 100) + 99) / 100 - 1),
caret
caret,
)
}
@ -315,7 +315,7 @@ internal class MotionGroup : VimMotionGroupBase() {
caret: Caret,
screenLocation: ScreenLocation,
visualLineOffset: Int,
normalizeToScreen: Boolean
normalizeToScreen: Boolean,
): @Range(from = 0, to = Int.MAX_VALUE.toLong()) Int {
val vimEditor = editor.vim
val scrollOffset = if (normalizeToScreen) getNormalizedScrollOffset(editor) else 0
@ -342,7 +342,7 @@ internal class MotionGroup : VimMotionGroupBase() {
caret: Caret,
context: DataContext?,
argument: Argument,
operatorArguments: OperatorArguments
operatorArguments: OperatorArguments,
): TextRange? {
var start: Int
var end: Int
@ -368,7 +368,7 @@ internal class MotionGroup : VimMotionGroupBase() {
caret.vim,
IjEditorExecutionContext(context!!),
cmd.argument,
operatorArguments.withCount0(raw)
operatorArguments.withCount0(raw),
)
// Invalid motion
@ -393,7 +393,7 @@ internal class MotionGroup : VimMotionGroupBase() {
if (cmd.isLinewiseMotion()) end--
} else {
throw RuntimeException(
"Commands doesn't take " + cmd.action.javaClass.simpleName + " as an operator"
"Commands doesn't take " + cmd.action.javaClass.simpleName + " as an operator",
)
}
}

View File

@ -61,9 +61,10 @@ internal class NotificationService(private val project: Project?) {
fun notifyAboutIdeaPut() {
val notification = Notification(
IDEAVIM_NOTIFICATION_ID, IDEAVIM_NOTIFICATION_TITLE,
IDEAVIM_NOTIFICATION_ID,
IDEAVIM_NOTIFICATION_TITLE,
"""Add <code>ideaput</code> to <code>clipboard</code> option to perform a put via the IDE<br/><b><code>set clipboard+=ideaput</code></b>""",
NotificationType.INFORMATION
NotificationType.INFORMATION,
)
notification.addAction(OpenIdeaVimRcAction(notification))
@ -72,13 +73,13 @@ internal class NotificationService(private val project: Project?) {
AppendToIdeaVimRcAction(
notification,
"set clipboard+=ideaput",
"ideaput"
"ideaput",
) {
val option = injector.optionGroup.getKnownStringOption(OptionConstants.clipboard)
injector.optionGroup.modifyOptionValue(option, OptionScope.GLOBAL) {
option.appendValue(it, VimString(OptionConstants.clipboard_ideaput))
}
}
},
)
notification.notify(project)
@ -86,9 +87,10 @@ internal class NotificationService(private val project: Project?) {
fun notifyAboutIdeaJoin() {
val notification = Notification(
IDEAVIM_NOTIFICATION_ID, IDEAVIM_NOTIFICATION_TITLE,
IDEAVIM_NOTIFICATION_ID,
IDEAVIM_NOTIFICATION_TITLE,
"""Put <b><code>set ideajoin</code></b> into your <code>~/.ideavimrc</code> to perform a join via the IDE""",
NotificationType.INFORMATION
NotificationType.INFORMATION,
)
notification.addAction(OpenIdeaVimRcAction(notification))
@ -97,11 +99,11 @@ internal class NotificationService(private val project: Project?) {
AppendToIdeaVimRcAction(
notification,
"set ideajoin",
IjOptionConstants.ideajoin
IjOptionConstants.ideajoin,
) {
val option = injector.optionGroup.getKnownToggleOption(IjOptionConstants.ideajoin)
injector.optionGroup.setToggleOption(option, OptionScope.GLOBAL)
}
},
)
notification.addAction(HelpLink(ideajoinExamplesUrl))
@ -113,7 +115,7 @@ internal class NotificationService(private val project: Project?) {
"(You can do it manually by running 'defaults write -g " +
"ApplePressAndHoldEnabled 0' in the console).",
IDEAVIM_NOTIFICATION_TITLE,
Messages.getQuestionIcon()
Messages.getQuestionIcon(),
)
fun noVimrcAsDefault() {
@ -122,7 +124,7 @@ internal class NotificationService(private val project: Project?) {
"The ~/.vimrc file is no longer read by default, use ~/.ideavimrc instead. You can read it from your " +
"~/.ideavimrc using this command:<br/><br/>" +
"<code>source ~/.vimrc</code>",
NotificationType.INFORMATION
NotificationType.INFORMATION,
)
notification.notify(project)
}
@ -143,7 +145,7 @@ internal class NotificationService(private val project: Project?) {
IDEAVIM_NOTIFICATION_ID,
IDEAVIM_NOTIFICATION_TITLE,
message,
NotificationType.INFORMATION
NotificationType.INFORMATION,
)
notification.addAction(object : DumbAwareAction("Use as IDE Shortcut") {
override fun actionPerformed(e: AnActionEvent) {
@ -162,17 +164,19 @@ internal class NotificationService(private val project: Project?) {
fun notifySubscribedToEap() {
Notification(
IDEAVIM_NOTIFICATION_ID, IDEAVIM_NOTIFICATION_TITLE,
IDEAVIM_NOTIFICATION_ID,
IDEAVIM_NOTIFICATION_TITLE,
"""You are successfully subscribed to IdeaVim EAP releases.""",
NotificationType.INFORMATION
NotificationType.INFORMATION,
).notify(project)
}
fun notifyEapFinished() {
Notification(
IDEAVIM_NOTIFICATION_ID, IDEAVIM_NOTIFICATION_TITLE,
IDEAVIM_NOTIFICATION_ID,
IDEAVIM_NOTIFICATION_TITLE,
"""You have finished the Early Access Program. Please reinstall IdeaVim to get the stable version.""",
NotificationType.INFORMATION
NotificationType.INFORMATION,
).notify(project)
}
@ -185,7 +189,6 @@ internal class NotificationService(private val project: Project?) {
private const val NO_ID = "<i>Cannot detect action id</i>"
fun notifyActionId(id: String?, project: Project?) {
notification?.expire()
val content = if (id != null) "Action id: $id" else NO_ID
@ -241,7 +244,7 @@ internal class NotificationService(private val project: Project?) {
@Suppress("DialogTitleCapitalization")
class OpenIdeaVimRcAction(private val notification: Notification?) : DumbAwareAction(
if (VimRcService.findIdeaVimRc() != null) "Open ~/.ideavimrc" else "Create ~/.ideavimrc"
if (VimRcService.findIdeaVimRc() != null) "Open ~/.ideavimrc" else "Create ~/.ideavimrc",
)/*, LightEditCompatible*/ {
override fun actionPerformed(e: AnActionEvent) {
val eventProject = e.project
@ -256,7 +259,7 @@ internal class NotificationService(private val project: Project?) {
notification?.expire()
createIdeaVimRcManually(
"Cannot create configuration file.<br/>Please create <code>~/.ideavimrc</code> manually",
eventProject
eventProject,
)
}
@ -288,7 +291,7 @@ internal class NotificationService(private val project: Project?) {
IDEAVIM_NOTIFICATION_ID,
IDEAVIM_NOTIFICATION_TITLE,
"<code>$optionName</code> is enabled",
NotificationType.INFORMATION
NotificationType.INFORMATION,
)
successNotification.addAction(OpenIdeaVimRcAction(successNotification))
successNotification.notify(project)
@ -298,7 +301,7 @@ internal class NotificationService(private val project: Project?) {
notification.expire()
createIdeaVimRcManually(
"Option is enabled, but the file is not modified<br/>Please modify <code>~/.ideavimrc</code> manually",
project
project,
)
}
}

View File

@ -23,8 +23,8 @@ internal class OptionGroup : VimOptionGroupBase() {
StringOption(
IjOptionConstants.ide,
IjOptionConstants.ide,
ApplicationNamesInfo.getInstance().fullProductNameWithEdition
)
ApplicationNamesInfo.getInstance().fullProductNameWithEdition,
),
)
addOption(ToggleOption(IjOptionConstants.ideacopypreprocess, IjOptionConstants.ideacopypreprocess, false))
addOption(ToggleOption(IjOptionConstants.ideajoin, IjOptionConstants.ideajoin, false))
@ -35,8 +35,8 @@ internal class OptionGroup : VimOptionGroupBase() {
IjOptionConstants.idearefactormode,
"select",
isList = false,
IjOptionConstants.ideaRefactorModeValues
)
IjOptionConstants.ideaRefactorModeValues,
),
)
addOption(
StringOption(
@ -44,8 +44,8 @@ internal class OptionGroup : VimOptionGroupBase() {
IjOptionConstants.ideastatusicon,
"enabled",
isList = false,
IjOptionConstants.ideaStatusIconValues
)
IjOptionConstants.ideaStatusIconValues,
),
)
addOption(
StringOption(
@ -53,8 +53,8 @@ internal class OptionGroup : VimOptionGroupBase() {
IjOptionConstants.ideavimsupport,
"dialog",
isList = true,
IjOptionConstants.ideavimsupportValues
)
IjOptionConstants.ideavimsupportValues,
),
)
addOption(
StringOption(
@ -62,16 +62,16 @@ internal class OptionGroup : VimOptionGroupBase() {
IjOptionConstants.ideawrite,
"all",
isList = false,
IjOptionConstants.ideaWriteValues
)
IjOptionConstants.ideaWriteValues,
),
)
addOption(
StringOption(
IjOptionConstants.lookupkeys,
IjOptionConstants.lookupkeys,
"<Tab>,<Down>,<Up>,<Enter>,<Left>,<Right>,<C-Down>,<C-Up>,<PageUp>,<PageDown>,<C-J>,<C-Q>",
isList = true
)
isList = true,
),
)
addOption(ToggleOption(IjOptionConstants.oldundo, IjOptionConstants.oldundo, true))
addOption(ToggleOption(IjOptionConstants.trackactionids, "tai", false))
@ -83,8 +83,8 @@ internal class OptionGroup : VimOptionGroupBase() {
OptionConstants.clipboard,
OptionConstants.clipboardAlias,
"ideaput,autoselect,exclude:cons\\|linux",
isList = true
)
isList = true,
),
)
addOption(ToggleOption("unifyjumps", "unifyjumps", true))

View File

@ -60,7 +60,7 @@ internal class ScrollGroup : VimScrollGroup {
val offset = injector.motion.moveCaretToLineWithStartOfLineOption(
editor,
editor.visualLineToBufferLine(caretVisualLine),
caret
caret,
)
caret.moveToOffset(offset)
return result.first
@ -81,7 +81,7 @@ internal class ScrollGroup : VimScrollGroup {
val offset = injector.motion.moveCaretToLineWithStartOfLineOption(
editor,
editor.visualLineToBufferLine(caretVisualLine),
caret
caret,
)
caret.moveToOffset(offset)
return result.first
@ -174,7 +174,7 @@ internal class ScrollGroup : VimScrollGroup {
editor: VimEditor,
screenLocation: ScreenLocation,
rawCount: Int,
start: Boolean
start: Boolean,
) {
val scrollOffset = getNormalizedScrollOffset(editor.ij)
val visualLine = if (rawCount == 0) {
@ -189,7 +189,7 @@ internal class ScrollGroup : VimScrollGroup {
// Make sure we scroll to an actual line, not virtual space
EditorHelper.scrollVisualLineToBottomOfScreen(
editor.ij,
editor.normalizeVisualLine(visualLine + scrollOffset)
editor.normalizeVisualLine(visualLine + scrollOffset),
)
}
}
@ -214,7 +214,7 @@ internal class ScrollGroup : VimScrollGroup {
caretVisualPosition.line,
EditorHelper.getVisualColumnAtLeftOfDisplay(ijEditor, caretVisualPosition.line) +
columns,
false
false,
)
// If the target column has an inlay preceding it, move passed it. This inlay will have been (incorrectly)

View File

@ -61,7 +61,7 @@ internal class VimJumpServiceImpl : VimJumpServiceBase(), PersistentStateCompone
val jump = Jump(
Integer.parseInt(jumpElement.getAttributeValue("line")),
Integer.parseInt(jumpElement.getAttributeValue("column")),
jumpElement.getAttributeValue("filename")
jumpElement.getAttributeValue("filename"),
)
jumps.add(jump)
}

View File

@ -112,7 +112,7 @@ internal class VimMarkServiceImpl : VimMarkServiceBase(), PersistentStateCompone
aMarkList.getAttributeValue("line").toInt(),
aMarkList.getAttributeValue("column").toInt(),
aMarkList.getAttributeValue("filename"),
aMarkList.getAttributeValue("protocol")
aMarkList.getAttributeValue("protocol"),
)
if (mark != null) {
globalMarks[mark.key] = mark
@ -144,7 +144,7 @@ internal class VimMarkServiceImpl : VimMarkServiceBase(), PersistentStateCompone
aMarkList.getAttributeValue("line").toInt(),
aMarkList.getAttributeValue("column").toInt(),
filename,
aMarkList.getAttributeValue("protocol")
aMarkList.getAttributeValue("protocol"),
)
if (mark != null) fmarks[mark.key] = mark
}
@ -289,7 +289,7 @@ internal class VimMarkServiceImpl : VimMarkServiceBase(), PersistentStateCompone
companion object {
private const val SAVE_MARK_COUNT = 20
private val logger = Logger.getInstance(
VimMarkServiceImpl::class.java.name
VimMarkServiceImpl::class.java.name,
)
}
}

View File

@ -88,7 +88,7 @@ internal class PutGroup : VimPutBase() {
IjVimCaret(caret),
text.typeInRegister,
data,
additionalData
additionalData,
).first()
val pointMarker = editor.document.createRangeMarker(startOffset, startOffset)
caret.moveToInlayAwareOffset(startOffset)
@ -102,7 +102,7 @@ internal class PutGroup : VimPutBase() {
logger.debug { "Transferable classes: ${text.transferableData.joinToString { it.javaClass.name }}" }
val origContent: TextBlockTransferable = injector.clipboardManager.setClipboardText(
text.text,
transferableData = text.transferableData
transferableData = text.transferableData,
) as TextBlockTransferable
val allContentsAfter = CopyPasteManager.getInstance().allContents
val sizeAfterInsert = allContentsAfter.size
@ -125,13 +125,17 @@ internal class PutGroup : VimPutBase() {
if (!caret.isValid) return@forEach
val caretPossibleEndOffset = lastPastedRegion?.endOffset ?: (startOffset + text.text.length)
val endOffset = if (data.indent) doIndent(
vimEditor,
IjVimCaret(caret),
vimContext,
startOffset,
val endOffset = if (data.indent) {
doIndent(
vimEditor,
IjVimCaret(caret),
vimContext,
startOffset,
caretPossibleEndOffset,
)
} else {
caretPossibleEndOffset
) else caretPossibleEndOffset
}
val vimCaret = caret.vim
injector.markService.setChangeMarks(vimCaret, TextRange(startOffset, endOffset))
injector.markService.setMark(vimCaret, MARK_CHANGE_POS, startOffset)
@ -142,7 +146,7 @@ internal class PutGroup : VimPutBase() {
endOffset,
text.typeInRegister,
subMode,
data.caretAfterInsertedText
data.caretAfterInsertedText,
)
}
}
@ -166,7 +170,7 @@ internal class PutGroup : VimPutBase() {
editor,
caret,
context,
TextRange(startLineOffset, endLineOffset)
TextRange(startLineOffset, endLineOffset),
)
return editor.getLineEndOffset(endLine, true)
}

View File

@ -115,7 +115,7 @@ internal object IdeaSelectionControl {
.enterSelectMode(editor.vim, VimPlugin.getVisualMotion().autodetectVisualSubmode(editor.vim))
VimStateMachine.Mode.INSERT -> VimPlugin.getChange().insertBeforeCursor(
editor.vim,
injector.executionContextManager.onEditor(editor.vim)
injector.executionContextManager.onEditor(editor.vim),
)
VimStateMachine.Mode.COMMAND -> Unit
else -> error("Unexpected mode: $mode")

View File

@ -115,12 +115,12 @@ internal fun isOctopusEnabled(s: KeyStroke, editor: Editor): Boolean {
s.keyCode == KeyEvent.VK_ENTER -> return editor.mode in listOf(
CommandState.Mode.COMMAND,
CommandState.Mode.INSERT,
CommandState.Mode.VISUAL
CommandState.Mode.VISUAL,
)
s.keyCode == KeyEvent.VK_ESCAPE -> return editor.mode in listOf(
CommandState.Mode.COMMAND,
CommandState.Mode.INSERT,
CommandState.Mode.VISUAL
CommandState.Mode.VISUAL,
)
}
return false

View File

@ -67,8 +67,12 @@ internal class IjActionExecutor : VimActionExecutor {
val ijAction = (action as IjNativeAction).action
val dataContext = VimDataContext(context.ij)
val event = AnActionEvent(
null, dataContext, ActionPlaces.KEYBOARD_SHORTCUT, ijAction.templatePresentation.clone(),
ActionManager.getInstance(), 0
null,
dataContext,
ActionPlaces.KEYBOARD_SHORTCUT,
ijAction.templatePresentation.clone(),
ActionManager.getInstance(),
0,
)
// beforeActionPerformedUpdate should be called to update the action. It fixes some rider-specific problems.
// because rider use async update method. See VIM-1819.
@ -166,8 +170,10 @@ internal class IjActionExecutor : VimActionExecutor {
.executeCommand(
editor.ij.project,
{ cmd.execute(editor, injector.executionContextManager.onEditor(editor, context), operatorArguments) },
cmd.id, DocCommandGroupId.noneGroupId(editor.ij.document), UndoConfirmationPolicy.DEFAULT,
editor.ij.document
cmd.id,
DocCommandGroupId.noneGroupId(editor.ij.document),
UndoConfirmationPolicy.DEFAULT,
editor.ij.document,
)
}

View File

@ -28,8 +28,8 @@ internal class IjEditorHelper : EngineEditorHelper {
VisualPosition(
pos.line,
pos.column,
pos.leansRight
)
pos.leansRight,
),
)
}

View File

@ -217,8 +217,9 @@ internal object ScrollViewHelper {
scrollColumnToLeftOfScreen(editor, position.line, max(0, currentVisualLeftColumn - diff))
} else {
scrollColumnToRightOfScreen(
editor, position.line,
vimEditor.normalizeVisualColumn(position.line, currentVisualRightColumn + diff, false)
editor,
position.line,
vimEditor.normalizeVisualColumn(position.line, currentVisualRightColumn + diff, false),
)
}
}

View File

@ -60,11 +60,15 @@ internal fun addSubstitutionConfirmationHighlight(editor: Editor, start: Int, en
editor.colorsScheme.getColor(EditorColors.SELECTION_FOREGROUND_COLOR),
editor.colorsScheme.getColor(EditorColors.SELECTION_BACKGROUND_COLOR),
editor.colorsScheme.getColor(EditorColors.CARET_COLOR),
EffectType.ROUNDED_BOX, Font.PLAIN
EffectType.ROUNDED_BOX,
Font.PLAIN,
)
return editor.markupModel.addRangeHighlighter(
start, end, HighlighterLayer.SELECTION,
color, HighlighterTargetArea.EXACT_RANGE
start,
end,
HighlighterLayer.SELECTION,
color,
HighlighterTargetArea.EXACT_RANGE,
)
}
@ -219,8 +223,11 @@ private fun highlightMatch(editor: Editor, start: Int, end: Int, current: Boolea
attributes.errorStripeColor = getFallbackErrorStripeColor(attributes, editor.colorsScheme)
}
val highlighter = editor.markupModel.addRangeHighlighter(
start, end, HighlighterLayer.SELECTION - 1,
attributes, HighlighterTargetArea.EXACT_RANGE
start,
end,
HighlighterLayer.SELECTION - 1,
attributes,
HighlighterTargetArea.EXACT_RANGE,
)
highlighter.errorStripeTooltip = tooltip
return highlighter

View File

@ -19,7 +19,6 @@ internal class TestInputModel private constructor() {
}
fun nextKeyStroke(): KeyStroke? {
// Return key from the unfinished mapping
/*
MappingStack mappingStack = KeyHandler.getInstance().getMappingStack();
@ -29,7 +28,9 @@ if (mappingStack.hasStroke()) {
*/
return if (myKeyStrokes.isNotEmpty()) {
myKeyStrokes.removeAt(0)
} else null
} else {
null
}
}
companion object {

View File

@ -117,10 +117,10 @@ internal object IdeaSpecifics {
//region Enter insert mode after surround with if
if (surrounderAction == action.javaClass.name && surrounderItems.any {
action.templatePresentation.text.endsWith(
it
action.templatePresentation.text.endsWith(
it,
)
}
}
) {
editor?.let {
val commandState = it.vim.vimStateMachine
@ -165,7 +165,7 @@ internal object IdeaSpecifics {
if (editor.inNormalMode) {
VimPlugin.getChange().insertBeforeCursor(
editor.vim,
injector.executionContextManager.onEditor(editor.vim)
injector.executionContextManager.onEditor(editor.vim),
)
KeyHandler.getInstance().reset(editor.vim)
}

View File

@ -174,7 +174,6 @@ internal object VimListenerManager {
}
fun remove(editor: Editor, isReleased: Boolean) {
editor.contentComponent.removeKeyListener(VimKeyListener)
val eventFacade = EventFacade.getInstance()
eventFacade.removeEditorMouseListener(editor, EditorMouseHandler)
@ -491,7 +490,9 @@ internal object VimListenerManager {
false
}
}
} else cutOffEnd = false
} else {
cutOffEnd = false
}
}
// Double-clicking a word in IntelliJ will select the word and locate the caret at the end of the selection,
// on the following character. When using a bar caret, this is drawn as between the end of selection and the
@ -516,7 +517,7 @@ internal object VimListenerManager {
enum class SelectionSource {
MOUSE,
OTHER
OTHER,
}
}

View File

@ -34,7 +34,7 @@ internal class IntellijMark(bookmark: LineBookmark, override val col: Int, proje
private fun getMark(): LineBookmark? =
getProject()?.let {
project ->
project ->
BookmarksManager.getInstance(project)?.getBookmark(BookmarkType.get(key)) as? LineBookmark
}

View File

@ -188,9 +188,9 @@ internal fun insertLineAround(editor: VimEditor, context: ExecutionContext, shif
editor.editor.document.getText(
com.intellij.openapi.util.TextRange(
initialLineStart.point,
lineStart.point
)
)
lineStart.point,
),
),
)
vimCaret.moveToOffset(lineStart.point)

View File

@ -90,8 +90,8 @@ internal class IjClipboardManager : VimClipboardManager {
file,
editor,
textRange.startOffsets,
textRange.endOffsets
)
textRange.endOffsets,
),
)
} catch (ignore: IndexNotReadyException) {
}
@ -119,8 +119,9 @@ internal class IjClipboardManager : VimClipboardManager {
val project = editor.project ?: return text
val file = PsiDocumentManager.getInstance(project).getPsiFile(editor.document) ?: return text
val rawText = TextBlockTransferable.convertLineSeparators(
text, "\n",
transferableData as Collection<TextBlockTransferableData?>
text,
"\n",
transferableData as Collection<TextBlockTransferableData?>,
)
if (injector.globalOptions().isSet(IjOptionConstants.ideacopypreprocess)) {
for (processor in CopyPastePreProcessor.EP_NAME.extensionList) {

View File

@ -86,7 +86,10 @@ internal class IjVimApplication : VimApplicationBase() {
return KeyEvent(
component,
if (stroke.keyChar == KeyEvent.CHAR_UNDEFINED) KeyEvent.KEY_PRESSED else KeyEvent.KEY_TYPED,
System.currentTimeMillis(), stroke.modifiers, stroke.keyCode, stroke.keyChar
System.currentTimeMillis(),
stroke.modifiers,
stroke.keyCode,
stroke.keyChar,
)
}

View File

@ -28,7 +28,7 @@ internal class IjVimDocument(private val document: Document) : VimDocument {
event.oldFragment.toString(),
event.newFragment.toString(),
event.offset,
)
),
)
}
}

View File

@ -94,7 +94,6 @@ internal class IjVimEditor(editor: Editor) : MutableLinearEditor() {
override fun addLine(atPosition: EditorLine.Offset): EditorLine.Pointer {
val offset: Int = if (atPosition.line < lineCount()) {
// The new line character is inserted before the new line char of the previous line. So it works line an enter
// on a line end. I believe that the correct implementation would be to insert the new line char after the
// \n of the previous line, however at the moment this won't update the mark on this line.
@ -190,7 +189,7 @@ internal class IjVimEditor(editor: Editor) : MutableLinearEditor() {
override fun search(
pair: Pair<Offset, Offset>,
editor: VimEditor,
shiftType: LineDeleteShift
shiftType: LineDeleteShift,
): Pair<Pair<Offset, Offset>, LineDeleteShift>? {
val ijEditor = (editor as IjVimEditor).editor
return when (shiftType) {
@ -391,8 +390,8 @@ internal class IjVimEditor(editor: Editor) : MutableLinearEditor() {
VisualPosition(
position.line,
position.column,
position.leansRight
)
position.leansRight,
),
)
return BufferPosition(logPosition.line, logPosition.column, logPosition.leansForward)
}

View File

@ -24,7 +24,7 @@ internal class IjVimSearchHelper : VimSearchHelperBase() {
(editor as IjVimEditor).editor,
(caret as IjVimCaret).caret,
count,
allowBlanks
allowBlanks,
)
}
@ -38,7 +38,9 @@ internal class IjVimSearchHelper : VimSearchHelperBase() {
return SearchHelper.findNextSentenceStart(
(editor as IjVimEditor).editor,
(caret as IjVimCaret).caret,
count, countCurrent, requireAll
count,
countCurrent,
requireAll,
)
}

View File

@ -107,7 +107,9 @@ internal class RegExp {
}
return if (c == Magic.STAR || c == Magic.PLUS || c == Magic.LCURLY) {
MULTI_MULT
} else NOT_MULTI
} else {
NOT_MULTI
}
}
/*
@ -589,8 +591,8 @@ internal class RegExp {
injector.messages.message(
Msg.E62,
`val`,
Character.toString(Magic.no_Magic(peekchr()).toChar())
)
Character.toString(Magic.no_Magic(peekchr()).toChar()),
),
)
}
return null
@ -618,7 +620,7 @@ internal class RegExp {
HEX, NHEX, OCTAL, NOCTAL,
WORD, NWORD, HEAD, NHEAD,
ALPHA, NALPHA, LOWER, NLOWER,
UPPER, NUPPER
UPPER, NUPPER,
)
val p: CharPointer
var extra = 0
@ -694,8 +696,8 @@ internal class RegExp {
injector.messages.message(
Msg.E64,
`val`,
Character.toString(c.toChar())
)
Character.toString(c.toChar()),
),
)
return null
}
@ -1096,9 +1098,9 @@ internal class RegExp {
* e.g., a "[" without matching "]".
*/len = 0
while (c != '\u0000'.code && (
len == 0 || re_multi_type(peekchr()) == NOT_MULTI &&
!one_exactly && !Magic.is_Magic(c)
)
len == 0 || re_multi_type(peekchr()) == NOT_MULTI &&
!one_exactly && !Magic.is_Magic(c)
)
) {
c = Magic.no_Magic(c)
regc(c)
@ -1254,8 +1256,8 @@ internal class RegExp {
* "\(", "\|", "\&' or "\n" */if (reg_magic >= MAGIC_OFF &&
(
at_start || reg_magic == MAGIC_ALL || prevchr == Magic.LPAREN || prevchr == Magic.PIPE || prevchr == Magic.AMP || prevchr == Magic.n || Magic.no_Magic(
prevchr
) == '('.code &&
prevchr,
) == '('.code &&
prevprevchr == Magic.PERCENT
)
) {
@ -1268,10 +1270,10 @@ internal class RegExp {
val p = regparse!!.ref(1)
/* ignore \c \C \m and \M after '$' */while (p.charAt(0) == '\\' && (
p.charAt(1) == 'c' || p.charAt(
1
p.charAt(1) == 'c' || p.charAt(
1,
) == 'C' || p.charAt(1) == 'm' || p.charAt(1) == 'M'
)
)
) {
p.inc(2)
}
@ -1457,9 +1459,11 @@ internal class RegExp {
* can't go before line 1 */
return if (reg_firstlnum + lnum < 0) {
null
} else CharPointer(
reg_buf!!.getLineBuffer(reg_firstlnum + lnum)
)
} else {
CharPointer(
reg_buf!!.getLineBuffer(reg_firstlnum + lnum),
)
}
// return ml_get_buf(reg_buf, reg_firstlnum + lnum, false);
}
@ -1493,7 +1497,7 @@ internal class RegExp {
buf: VimEditor?,
lcount: Int,
lnum: Int,
col: Int
col: Int,
): Int /* window in which to search or null */ /* buffer in which to search */ /* nr of line to start looking for match */ /* column to start looking for match */ {
val r: Int
// VimEditor save_curbuf = curbuf;
@ -1747,9 +1751,9 @@ internal class RegExp {
/* Only accept single line matches. */
if (reg_startzpos[i]!!.lnum >= 0 && reg_endzpos[i]!!.lnum == reg_startzpos[i]!!.lnum) {
re_extmatch_out!!.matches[i] = reg_getline(
reg_startzpos[i]!!.lnum
reg_startzpos[i]!!.lnum,
)!!.ref(reg_startzpos[i]!!.col).substring(
reg_endzpos[i]!!.col - reg_startzpos[i]!!.col
reg_endzpos[i]!!.col - reg_startzpos[i]!!.col,
)
}
} else {
@ -1813,7 +1817,7 @@ internal class RegExp {
RE_BOF -> /* Passing -1 to the getline() function provided for the search
* should always return null if the current line is the first
* line of the file. */if (reglnum != 0 || !reginput!!.equals(regline) || reg_match == null && reg_getline(
-1
-1,
) != null
) {
return false
@ -1832,7 +1836,8 @@ internal class RegExp {
}
}
RE_LNUM -> if (reg_match != null || !re_num_cmp(
reglnum + reg_firstlnum, scan
reglnum + reg_firstlnum,
scan,
)
) {
return false
@ -2028,9 +2033,9 @@ internal class RegExp {
var opnd: CharPointer
opnd = scan.OPERAND()
/* Inline the first byte, for speed. */if (opnd.charAt() != reginput!!.charAt() && (
!ireg_ic ||
opnd.charAt().lowercaseChar() != reginput!!.charAt().lowercaseChar()
)
!ireg_ic ||
opnd.charAt().lowercaseChar() != reginput!!.charAt().lowercaseChar()
)
) {
return false
}
@ -2041,7 +2046,7 @@ internal class RegExp {
/* Need to match first byte again for multi-byte. */if (cstrncmp(
opnd,
reginput!!,
len
len,
) != 0
) {
return false
@ -2148,7 +2153,6 @@ internal class RegExp {
ccol = reg_startpos[no]!!.col
clnum = reg_startpos[no]!!.lnum
while (true) {
/* Since getting one line may invalidate
* the other, need to make copy. Slow! */if (!regline!!.equals(reg_tofree)) {
reg_tofree = regline!!.ref(0)
@ -2358,7 +2362,6 @@ internal class RegExp {
return false
}
while (true) {
/* If it could work, try it. */if (nextb == '\u0000' || reginput!!.charAt() == nextb || reginput!!.charAt() == nextb_ic) {
reg_save(save)
if (regmatch(next)) {
@ -2368,7 +2371,7 @@ internal class RegExp {
}
/* Couldn't or didn't match: try advancing one char. */if (count == minval || regrepeat(
scan.OPERAND(),
1
1,
) == 0
) {
break
@ -2425,9 +2428,13 @@ internal class RegExp {
* result, hitting the start of the line or the previous
* line (for multi-line matching).
* Set behind_pos to where the match should end, BHPOS
* will match it. */save_behind_pos = if (behind_pos == null) null else regsave_T(
behind_pos!!
)
* will match it. */save_behind_pos = if (behind_pos == null) {
null
} else {
regsave_T(
behind_pos!!,
)
}
behind_pos = regsave_T(save_start)
while (true) {
reg_restore(save_start)
@ -2942,7 +2949,9 @@ internal class RegExp {
private fun reg_save_equal(save: regsave_T): Boolean {
return if (reg_match == null) {
reglnum == save.pos.lnum && reginput!!.equals(regline!!.ref(save.pos.col))
} else reginput!!.equals(save.ptr)
} else {
reginput!!.equals(save.ptr)
}
}
/*
@ -2970,7 +2979,9 @@ internal class RegExp {
if (reg_match == null) {
posp.col = savep.pos.col
posp.lnum = savep.pos.lnum
} else pp?.assign(savep.ptr!!)
} else {
pp?.assign(savep.ptr!!)
}
}
/*
@ -2983,7 +2994,9 @@ internal class RegExp {
}
return if (scan.OPERAND_CMP() == '<') {
`val` < n
} else `val` == n
} else {
`val` == n
}
}
/*
@ -3664,6 +3677,7 @@ internal class RegExp {
@JvmField
var lnum = 0
@JvmField
var col = 0
override fun toString(): String {
@ -3702,10 +3716,13 @@ internal class RegExp {
class regmmatch_T {
@JvmField
var regprog: regprog_T? = null
@JvmField
var startpos = arrayOfNulls<lpos_T>(NSUBEXP)
@JvmField
var endpos = arrayOfNulls<lpos_T>(NSUBEXP)
@JvmField
var rmm_ic = false
@ -3965,7 +3982,7 @@ internal class RegExp {
1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, /* P S U V W X [ _ */
1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, /* a c d f h i k l m n o */
0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, /* p s u v w x z { | ~ */
1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1
1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1,
)
/* arguments for reg() */
@ -3988,7 +4005,7 @@ internal class RegExp {
i = 0
while (i < (CharacterClasses.CLASS_NAMES?.size ?: 0)) {
if (pp.ref(2)
.strncmp(CharacterClasses.CLASS_NAMES!![i], CharacterClasses.CLASS_NAMES[i].length) == 0
.strncmp(CharacterClasses.CLASS_NAMES!![i], CharacterClasses.CLASS_NAMES[i].length) == 0
) {
pp.inc(CharacterClasses.CLASS_NAMES[i].length + 2)
return i

View File

@ -18,11 +18,11 @@ internal class ActionTracker : CounterUsagesCollector() {
private val GROUP = EventLogGroup("vim.actions", 1)
private val TRACKED_ACTIONS = GROUP.registerEvent(
"tracked",
EventFields.StringValidatedByCustomRule("action_id", ActionRuleValidator::class.java)
EventFields.StringValidatedByCustomRule("action_id", ActionRuleValidator::class.java),
)
private val COPIED_ACTIONS = GROUP.registerEvent(
"copied",
EventFields.StringValidatedByCustomRule("action_id", ActionRuleValidator::class.java)
EventFields.StringValidatedByCustomRule("action_id", ActionRuleValidator::class.java),
)
fun logTrackedAction(actionId: String) {

View File

@ -38,8 +38,8 @@ internal class OptionsState : ApplicationUsagesCollector() {
IDEASTATUSICON withOption IjOptionConstants.ideastatusicon,
IDEAWRITE withOption IjOptionConstants.ideawrite,
IDEASELECTION with globalOptions.hasValue(OptionConstants.selectmode, "ideaselection"),
IDEAVIMSUPPORT withOption IjOptionConstants.ideavimsupport
)
IDEAVIMSUPPORT withOption IjOptionConstants.ideavimsupport,
),
)
}

View File

@ -26,7 +26,7 @@ internal class PluginState : ApplicationUsagesCollector() {
PLUGIN_ENABLED with VimPlugin.isEnabled(),
IS_EAP with JoinEap.eapActive(),
ENABLED_EXTENSIONS with enabledExtensions.toList(),
)
),
)
}

View File

@ -32,7 +32,7 @@ internal class VimscriptState : ApplicationUsagesCollector() {
IS_MAP_EXPR_USED with isMapExprUsed,
IS_FUNCTION_DEF_USED with isFunctionDeclarationUsed,
IS_FUNCTION_CALL_USED with isFunctionCallUsed,
)
),
)
}

View File

@ -23,7 +23,6 @@ import javax.swing.KeyStroke
*/
public object ModalEntry {
public inline fun activate(editor: VimEditor, crossinline processor: (KeyStroke) -> Boolean) {
// Firstly we pull the unfinished keys of the current mapping
val mappingStack = KeyHandler.getInstance().keyStack
var stroke = mappingStack.feedSomeStroke()

View File

@ -135,8 +135,11 @@ internal class ReloadVimRc : DumbAwareAction() {
// XXX: Actually, it worth to add e.presentation.description, but it doesn't work because of some reason
val sameDoc = VimRcFileState.equalTo(editor.document)
e.presentation.icon = if (sameDoc) VimIcons.IDEAVIM else AllIcons.Actions.BuildLoadChanges
e.presentation.text = if (sameDoc) MessageHelper.message("action.no.changes.text")
else MessageHelper.message("action.reload.text")
e.presentation.text = if (sameDoc) {
MessageHelper.message("action.no.changes.text")
} else {
MessageHelper.message("action.reload.text")
}
e.presentation.isEnabledAndVisible = true
}

View File

@ -155,9 +155,12 @@ private object VimActionsPopup {
val actions = getActions()
val popup = JBPopupFactory.getInstance()
.createActionGroupPopup(
STATUS_BAR_DISPLAY_NAME, actions,
dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false,
ActionPlaces.POPUP
STATUS_BAR_DISPLAY_NAME,
actions,
dataContext,
JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
false,
ActionPlaces.POPUP,
)
popup.setAdText(MessageHelper.message("popup.advertisement.version", VimPlugin.getVersion()), SwingConstants.CENTER)
@ -176,8 +179,8 @@ private object VimActionsPopup {
HelpLink(
MessageHelper.message("action.plugins"),
"https://jb.gg/ideavim-plugins",
null
)
null,
),
)
actionGroup.addSeparator(MessageHelper.message("action.eap.choice.active.text"))
@ -186,8 +189,8 @@ private object VimActionsPopup {
HelpLink(
MessageHelper.message("action.about.eap.text"),
"https://github.com/JetBrains/ideavim#get-early-access",
null
)
null,
),
)
actionGroup.addSeparator("Learn")
@ -199,22 +202,22 @@ private object VimActionsPopup {
HelpLink(
MessageHelper.message("action.contact.on.twitter.text"),
"https://twitter.com/ideavim",
VimIcons.TWITTER
)
VimIcons.TWITTER,
),
)
actionGroup.add(
HelpLink(
MessageHelper.message("action.create.issue.text"),
"https://youtrack.jetbrains.com/newIssue?project=VIM&description=%0A%0A-----------%0AYou%20can%20improve%20the%20issue%20description%20by%20providing%3A%0A1)%20Your%20%60~%2F.ideavimrc%60%20configuration%20if%20you%20use%20it.%0A2)%20The%20%5Blog%5D(https%3A%2F%2Fintellij-support.jetbrains.com%2Fhc%2Fen-us%2Farticles%2F207241085-Locating-IDE-log-files)%20from%20your%20IDE.%0A%0AVersion:%20${VimPlugin.getVersion()}&c=Affected%20versions%20${VimPlugin.getVersion()}",
VimIcons.YOUTRACK
)
VimIcons.YOUTRACK,
),
)
actionGroup.add(
HelpLink(
MessageHelper.message("action.contribute.on.github.text"),
"https://github.com/JetBrains/ideavim",
AllIcons.Vcs.Vendors.Github
)
AllIcons.Vcs.Vendors.Github,
),
)
return actionGroup

View File

@ -116,7 +116,7 @@ internal class VimEmulationConfigurable : Configurable {
helpLine.text = message(
"configurable.noneditablehandler.helper.text.with.example",
(firstPerMode.owner as PerMode).toNotation(),
KeymapUtil.getShortcutText(KeyboardShortcut(firstPerMode.keyStroke, null))
KeymapUtil.getShortcutText(KeyboardShortcut(firstPerMode.keyStroke, null)),
)
helpLine.foreground = UIUtil.getInactiveTextColor()
add(helpLine, BorderLayout.SOUTH)
@ -185,7 +185,8 @@ internal class VimEmulationConfigurable : Configurable {
private enum class Column(val index: Int, val title: @Nls(capitalization = Nls.Capitalization.Title) String) {
KEYSTROKE(0, "Shortcut"),
IDE_ACTION(1, "IDE Action"),
OWNER(2, "Handler");
OWNER(2, "Handler"),
;
companion object {
private val ourMembers: MutableMap<Int, Column> = HashMap()
@ -296,7 +297,7 @@ internal class VimEmulationConfigurable : Configurable {
) : DumbAwareActionButton(
"Copy Config for .ideavimrc",
"Copy config for .ideavimrc in sethandler format",
AllIcons.Actions.Copy
AllIcons.Actions.Copy,
) {
override fun updateButton(e: AnActionEvent) {

View File

@ -229,8 +229,12 @@ internal class DeletePreviousWordAction : TextAction(DefaultEditorKit.deletePrev
val doc = target.document
val caret = target.caret
val offset = VimSearchHelperBase.Companion.findNextWord(
target.actualText, caret.dot.toLong(), target.actualText.length.toLong(),
-1, false, false
target.actualText,
caret.dot.toLong(),
target.actualText.length.toLong(),
-1,
false,
false,
)
if (logger.isDebugEnabled) logger.debug("offset=$offset")
try {

View File

@ -108,7 +108,7 @@ internal object ExEditorKit : DefaultEditorKit() {
HistoryUpFilterAction(),
HistoryDownFilterAction(),
ToggleInsertReplaceAction(),
InsertRegisterAction()
InsertRegisterAction(),
)
class DefaultExKeyHandler : DefaultKeyTypedAction() {
@ -128,7 +128,7 @@ internal object ExEditorKit : DefaultEditorKit() {
KeyHandler.getInstance().handleKey(
editor.vim,
key,
injector.executionContextManager.onEditor(editor.vim, entry.context.vim)
injector.executionContextManager.onEditor(editor.vim, entry.context.vim),
)
} else {
val event = ActionEvent(e.source, e.id, c.toString(), e.getWhen(), e.modifiers)

View File

@ -75,7 +75,7 @@ internal object ExKeyBindings {
// These appear to be non-Vim shortcuts
KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.META_DOWN_MASK), DefaultEditorKit.pasteAction),
KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, KeyEvent.SHIFT_DOWN_MASK), DefaultEditorKit.pasteAction)
KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, KeyEvent.SHIFT_DOWN_MASK), DefaultEditorKit.pasteAction),
)
}
}

View File

@ -39,7 +39,7 @@ internal class ExShortcutKeyAction(private val exEntryPanel: ExEntryPanel) : Dum
KeyHandler.getInstance().handleKey(
editor.vim,
keyStroke,
injector.executionContextManager.onEditor(editor.vim, e.dataContext.vim)
injector.executionContextManager.onEditor(editor.vim, e.dataContext.vim),
)
}
}
@ -57,7 +57,6 @@ internal class ExShortcutKeyAction(private val exEntryPanel: ExEntryPanel) : Dum
}
fun registerCustomShortcutSet() {
val shortcuts = ExKeyBindings.bindings.map {
KeyboardShortcut(it.key, null)
}.toTypedArray()

View File

@ -75,8 +75,13 @@ internal data class BufferListCommand(val ranges: Ranges, val argument: String)
bufferList.add(
String.format(
" %${bufNumPad}s %s %s%${lineNumPad}s line: %d", index, bufStatus, displayFileName, "", lineNum
)
" %${bufNumPad}s %s %s%${lineNumPad}s line: %d",
index,
bufStatus,
displayFileName,
"",
lineNum,
),
)
}
index++

View File

@ -34,9 +34,10 @@ internal class HasFunctionHandler : FunctionHandler() {
if (feature == "ide") {
VimscriptState.isIDESpecificConfigurationUsed = true
}
return if (supportedFeatures.contains(feature))
return if (supportedFeatures.contains(feature)) {
VimInt.ONE
else
} else {
VimInt.ZERO
}
}
}

View File

@ -27,7 +27,7 @@ internal class IdeavimErrorListener : BaseErrorListener() {
line: Int,
charPositionInLine: Int,
msg: String?,
e: RecognitionException?
e: RecognitionException?,
) {
VimscriptParser.linesWithErrors.add(line)
val message = "line $line:$charPositionInLine $msg"

View File

@ -212,7 +212,7 @@ internal object CommandVisitor : VimscriptBaseVisitor<Command>() {
ranges = Ranges()
ranges.addRange(
createRange(ctx.shortRange().text, 0, false)
?: throw ExException("Could not create a range")
?: throw ExException("Could not create a range"),
)
}
return GoToLineCommand(ranges)
@ -252,10 +252,11 @@ internal object CommandVisitor : VimscriptBaseVisitor<Command>() {
}
}
SplitCommand::class -> {
if (commandName.startsWith("v"))
if (commandName.startsWith("v")) {
SplitCommand(ranges, argument, SplitType.VERTICAL)
else
} else {
SplitCommand(ranges, argument, SplitType.HORIZONTAL)
}
}
SubstituteCommand::class -> SubstituteCommand(ranges, argument, commandName)
else -> getCommandByName(commandName).primaryConstructor!!.call(ranges, argument)

View File

@ -101,8 +101,8 @@ internal object ExecutableVisitor : VimscriptBaseVisitor<Executable>() {
catchBlocks.add(
CatchBlock(
catchBlock.pattern()?.patternBody()?.text ?: ".",
catchBlock.blockMember().mapNotNull { visitBlockMember(it) }
)
catchBlock.blockMember().mapNotNull { visitBlockMember(it) },
),
)
}
var finallyBlock: FinallyBlock? = null
@ -126,19 +126,19 @@ internal object ExecutableVisitor : VimscriptBaseVisitor<Executable>() {
val conditionToBody: MutableList<Pair<Expression, List<Executable>>> = mutableListOf()
conditionToBody.add(
ExpressionVisitor.visit(ctx.ifBlock().expr()) to ctx.ifBlock().blockMember()
.mapNotNull { visitBlockMember(it) }
.mapNotNull { visitBlockMember(it) },
)
if (ctx.elifBlock() != null) {
conditionToBody.addAll(
ctx.elifBlock().map {
ExpressionVisitor.visit(it.expr()) to it.blockMember().mapNotNull { it2 -> visitBlockMember(it2) }
}
},
)
}
if (ctx.elseBlock() != null) {
conditionToBody.add(
SimpleExpression(1) to ctx.elseBlock().blockMember()
.mapNotNull { visitBlockMember(it) }
.mapNotNull { visitBlockMember(it) },
)
}
return IfStatement(conditionToBody)

View File

@ -124,7 +124,7 @@ internal object ExpressionVisitor : VimscriptBaseVisitor<Expression>() {
val index = SimpleExpression(ctx.expr(1).text)
OneElementSublistExpression(index, left)
} else if (operatorString == "-" && left is OneElementSublistExpression && !containsSpaces(ctx) && matchesLiteralDictionaryKey(
ctx.expr(1).text
ctx.expr(1).text,
)
) {
val postfix = "-" + ctx.expr(1).text

View File

@ -35,7 +35,7 @@ internal class FunctionStorage : VimscriptFunctionService {
throw ExException("E128: Function name must start with a capital or \"s:\": $name")
}
if (scope != null)
if (scope != null) {
when (scope) {
Scope.GLOBAL_VARIABLE -> {
if (globalFunctions.containsKey(name)) {
@ -60,6 +60,7 @@ internal class FunctionStorage : VimscriptFunctionService {
}
else -> throw ExException("E130: Unknown function: ${scope.c}:$name")
}
}
if (globalFunctions.containsKey(name)) {
globalFunctions[name]!!.isDeleted = true

View File

@ -56,7 +56,7 @@ internal object NeovimTesting {
"--headless",
"--clean",
"--cmd", "set noswapfile",
"--cmd", "set sol"
"--cmd", "set sol",
)
neovim = pb.start()

View File

@ -67,7 +67,7 @@ inline fun waitAndAssert(timeInMillis: Int = 1000, condition: () -> Boolean) {
fun waitAndAssertMode(
fixture: CodeInsightTestFixture,
mode: VimStateMachine.Mode,
timeInMillis: Int? = null
timeInMillis: Int? = null,
) {
val timeout = timeInMillis ?: (injector.globalOptions().getIntValue(IjOptionConstants.visualdelay) + 1000)
waitAndAssert(timeout) { fixture.editor.editorMode == mode }
@ -99,9 +99,9 @@ fun waitCondition(
): Boolean {
val endTime = System.currentTimeMillis() + durationMillis
while (System.currentTimeMillis() < endTime) {
if (condition())
if (condition()) {
return true
else {
} else {
Thread.sleep(interval)
}
}

View File

@ -97,7 +97,7 @@ abstract class VimTestCase : UsefulTestCase() {
val fixture = fixtureBuilder.fixture
myFixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(
fixture,
LightTempDirTestFixtureImpl(true)
LightTempDirTestFixtureImpl(true),
)
myFixture.setUp()
myFixture.testDataPath = testDataPath
@ -284,7 +284,6 @@ abstract class VimTestCase : UsefulTestCase() {
@JvmOverloads
protected fun setPositionAndScroll(scrollToLogicalLine: Int, caretLogicalLine: Int, caretLogicalColumn: Int = 0) {
// Note that it is possible to request a position which would be invalid under normal Vim!
// We disable scrolloff + scrolljump, position as requested, and reset. When resetting scrolloff, Vim will
// recalculate the correct offsets, and that could move the top and/or caret line
@ -306,7 +305,7 @@ abstract class VimTestCase : UsefulTestCase() {
// Belt and braces. Let's make sure that the caret is fully onscreen
val bottomLogicalLine = myFixture.editor.vim.visualLineToBufferLine(
EditorHelper.getVisualLineAtBottomOfScreen(myFixture.editor)
EditorHelper.getVisualLineAtBottomOfScreen(myFixture.editor),
)
assertTrue(bottomLogicalLine >= caretLogicalLine)
assertTrue(caretLogicalLine >= scrollToLogicalLine)
@ -319,7 +318,7 @@ abstract class VimTestCase : UsefulTestCase() {
NeovimTesting.typeCommand(
keys.filterNotNull().joinToString(separator = "") { injector.parser.toKeyNotation(it) },
this,
editor
editor,
)
val project = myFixture.project
when (Checks.keyHandler) {
@ -354,7 +353,7 @@ abstract class VimTestCase : UsefulTestCase() {
protected fun options(): OptionValueAccessor {
assertNotNull(
"Editor is null! Move the call to after editor is initialised, or use optionsNoEditor",
myFixture.editor
myFixture.editor,
)
return injector.options(myFixture.editor.vim)
}
@ -407,7 +406,7 @@ abstract class VimTestCase : UsefulTestCase() {
Assert.assertEquals(
"Wrong amount of carets. Did you mean to use assertPosition?",
expectedOffsets.size,
carets.size
carets.size,
)
}
Assert.assertEquals("Wrong amount of carets", expectedOffsets.size, carets.size)
@ -663,7 +662,7 @@ abstract class VimTestCase : UsefulTestCase() {
ActionPlaces.KEYBOARD_SHORTCUT,
VimShortcutKeyAction.instance.templatePresentation.clone(),
ActionManager.getInstance(),
0
0,
)
if (ActionUtil.lastUpdateAndCheckDumb(VimShortcutKeyAction.instance, e, true)) {
ActionUtil.performActionDumbAwareWithCallbacks(VimShortcutKeyAction.instance, e)
@ -708,7 +707,8 @@ abstract class VimTestCase : UsefulTestCase() {
key = inputModel.nextKeyStroke()
}
},
null, null
null,
null,
)
}

View File

@ -22,7 +22,7 @@ class AutoIndentTest : VimTestCase() {
int <caret>b;
int c;
}
"""
""",
)
typeText(injector.parser.parseKeys("=="))
assertState(
@ -31,7 +31,7 @@ class AutoIndentTest : VimTestCase() {
<caret>int b;
int c;
}
"""
""",
)
}
@ -45,7 +45,7 @@ class AutoIndentTest : VimTestCase() {
int c;
int d;
}
"""
""",
)
typeText(injector.parser.parseKeys("2=="))
assertState(
@ -55,7 +55,7 @@ class AutoIndentTest : VimTestCase() {
int c;
int d;
}
"""
""",
)
}
@ -69,7 +69,7 @@ class AutoIndentTest : VimTestCase() {
int <caret>c;
int d;
}
"""
""",
)
typeText(injector.parser.parseKeys("=k"))
assertState(
@ -79,7 +79,7 @@ class AutoIndentTest : VimTestCase() {
int c;
int d;
}
"""
""",
)
}
@ -92,7 +92,7 @@ class AutoIndentTest : VimTestCase() {
int <caret>b;
int c;
}
"""
""",
)
typeText(injector.parser.parseKeys("=l"))
assertState(
@ -101,7 +101,7 @@ class AutoIndentTest : VimTestCase() {
<caret>int b;
int c;
}
"""
""",
)
}
@ -115,7 +115,7 @@ class AutoIndentTest : VimTestCase() {
int c;
int d;
}
"""
""",
)
typeText(injector.parser.parseKeys("2=j"))
assertState(
@ -125,7 +125,7 @@ class AutoIndentTest : VimTestCase() {
int c;
int d;
}
"""
""",
)
}
@ -138,7 +138,7 @@ class AutoIndentTest : VimTestCase() {
int <caret>b;
int c;
}
"""
""",
)
typeText(injector.parser.parseKeys("v" + "l" + "="))
assertState(
@ -147,7 +147,7 @@ class AutoIndentTest : VimTestCase() {
<caret>int b;
int c;
}
"""
""",
)
}
@ -161,7 +161,7 @@ class AutoIndentTest : VimTestCase() {
int c;
int d;
}
"""
""",
)
typeText(injector.parser.parseKeys("v" + "j" + "="))
assertState(
@ -171,7 +171,7 @@ class AutoIndentTest : VimTestCase() {
int c;
int d;
}
"""
""",
)
}
@ -185,7 +185,7 @@ class AutoIndentTest : VimTestCase() {
int c;
int d;
}
"""
""",
)
typeText(injector.parser.parseKeys("<C-V>" + "j" + "="))
assertState(
@ -195,7 +195,7 @@ class AutoIndentTest : VimTestCase() {
int c;
int d;
}
"""
""",
)
}
}

View File

@ -23,8 +23,11 @@ class ChangeActionTest : VimTestCase() {
// VIM-620 |i_CTRL-O|
fun testInsertSingleCommandAndInserting() {
doTest(
listOf("i", "<C-O>", "a", "123", "<Esc>", "x"), "abc${c}d\n", "abcd12\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
listOf("i", "<C-O>", "a", "123", "<Esc>", "x"),
"abc${c}d\n",
"abcd12\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -32,7 +35,10 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommandAndNewLineInserting() {
doTest(
listOf("i", "<C-O>", "o", "123", "<Esc>", "x"),
"abc${c}d\n", "abcd\n12\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
"abc${c}d\n",
"abcd\n12\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -40,7 +46,10 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommandAndNewLineInserting2() {
doTest(
listOf("i", "<C-O>", "v"),
"12${c}345", "12${s}${c}3${se}45", VimStateMachine.Mode.INSERT_VISUAL, VimStateMachine.SubMode.VISUAL_CHARACTER
"12${c}345",
"12${s}${c}3${se}45",
VimStateMachine.Mode.INSERT_VISUAL,
VimStateMachine.SubMode.VISUAL_CHARACTER,
)
}
@ -48,7 +57,10 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommandAndNewLineInserting3() {
doTest(
listOf("i", "<C-O>", "v", "<esc>"),
"12${c}345", "12${c}345", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
"12${c}345",
"12${c}345",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -56,7 +68,10 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommandAndNewLineInserting4() {
doTest(
listOf("i", "<C-O>", "v", "d"),
"12${c}345", "12${c}45", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
"12${c}345",
"12${c}45",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -65,7 +80,10 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommandAndNewLineInserting5() {
doTest(
listOf("i", "<C-O>", "v", "<C-G>"),
"12${c}345", "12${s}3${c}${se}45", VimStateMachine.Mode.INSERT_SELECT, VimStateMachine.SubMode.VISUAL_CHARACTER
"12${c}345",
"12${s}3${c}${se}45",
VimStateMachine.Mode.INSERT_SELECT,
VimStateMachine.SubMode.VISUAL_CHARACTER,
)
}
@ -74,7 +92,10 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommandAndNewLineInserting6() {
doTest(
listOf("i", "<C-O>", "gh"),
"12${c}345", "12${s}3${c}${se}45", VimStateMachine.Mode.INSERT_SELECT, VimStateMachine.SubMode.VISUAL_CHARACTER
"12${c}345",
"12${s}3${c}${se}45",
VimStateMachine.Mode.INSERT_SELECT,
VimStateMachine.SubMode.VISUAL_CHARACTER,
)
}
@ -83,7 +104,10 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommandAndNewLineInserting7() {
doTest(
listOf("i", "<C-O>", "gh", "<esc>"),
"12${c}345", "123${c}45", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
"12${c}345",
"123${c}45",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -102,7 +126,10 @@ class ChangeActionTest : VimTestCase() {
fun testInsertSingleCommand() {
doTest(
listOf("i", "def", "<C-O>", "d2h", "x"),
"abc$c.\n", "abcdx.\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
"abc$c.\n",
"abcdx.\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -127,8 +154,11 @@ class ChangeActionTest : VimTestCase() {
fun testChangeUpperCase() {
doTest(
"gUw", "${c}FooBar Baz\n", "FOOBAR Baz\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
"gUw",
"${c}FooBar Baz\n",
"FOOBAR Baz\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -138,22 +168,31 @@ class ChangeActionTest : VimTestCase() {
fun testToggleCaseVisual() {
doTest(
"ve~", "${c}FooBar Baz\n", "fOObAR Baz\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
"ve~",
"${c}FooBar Baz\n",
"fOObAR Baz\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
fun testChangeUpperCaseVisual() {
doTest(
"veU", "${c}FooBar Baz\n", "FOOBAR Baz\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
"veU",
"${c}FooBar Baz\n",
"FOOBAR Baz\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
fun testChangeLowerCaseVisual() {
doTest(
"veu", "${c}FooBar Baz\n", "foobar Baz\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
"veu",
"${c}FooBar Baz\n",
"foobar Baz\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -173,7 +212,8 @@ class ChangeActionTest : VimTestCase() {
four
""".trimIndent(),
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -191,7 +231,8 @@ class ChangeActionTest : VimTestCase() {
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
assertOffset(4)
}
@ -211,7 +252,7 @@ class ChangeActionTest : VimTestCase() {
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -231,7 +272,8 @@ class ChangeActionTest : VimTestCase() {
three
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -245,7 +287,8 @@ class ChangeActionTest : VimTestCase() {
"""one
three
""",
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
assertOffset(3)
}
@ -259,16 +302,20 @@ class ChangeActionTest : VimTestCase() {
three four
""".trimIndent(),
"one four\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
"one four\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
// VIM-1380 |d| |w| |count|
fun testDeleteTwoWordsAtLastChar() {
doTest(
"d2w", "on${c}e two three\n", "on${c}three\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
"d2w",
"on${c}e two three\n",
"on${c}three\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -283,7 +330,7 @@ class ChangeActionTest : VimTestCase() {
, baz
""",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -302,7 +349,7 @@ class ChangeActionTest : VimTestCase() {
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -320,7 +367,8 @@ class ChangeActionTest : VimTestCase() {
bar
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
assertOffset(1)
}
@ -334,7 +382,9 @@ class ChangeActionTest : VimTestCase() {
two
""".trimIndent(),
"two\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
"two\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -342,8 +392,11 @@ class ChangeActionTest : VimTestCase() {
fun testInsertFromRegister() {
setRegister('a', "World")
doTest(
listOf("A", ", ", "<C-R>", "a", "!"), "${c}Hello\n", "Hello, World!\n", VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE
listOf("A", ", ", "<C-R>", "a", "!"),
"${c}Hello\n",
"Hello, World!\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -351,7 +404,10 @@ class ChangeActionTest : VimTestCase() {
fun testInsertNewLineAboveFirstLine() {
doTest(
listOf("O", "bar"),
"fo${c}o\n", "bar\nfoo\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
"fo${c}o\n",
"bar\nfoo\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -359,7 +415,10 @@ class ChangeActionTest : VimTestCase() {
fun testVisualSelectionRightMargin() {
doTest(
listOf("v", "k\$d"),
"foo\n${c}bar\n", "fooar\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
"foo\n${c}bar\n",
"fooar\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -381,7 +440,8 @@ class ChangeActionTest : VimTestCase() {
quux
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -402,7 +462,8 @@ class ChangeActionTest : VimTestCase() {
quux
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -417,7 +478,8 @@ quux
""" a 1 b 2 c 3
quux
""",
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -432,7 +494,8 @@ quux
""" a 1 b 2 c 3
quux
""",
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -445,7 +508,9 @@ quux
bar
""".dotToSpace().trimIndent(),
"foo bar", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
"foo bar",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -456,7 +521,9 @@ quux
foo..
bar
""".dotToSpace().trimIndent(),
"foo bar", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
"foo bar",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -471,7 +538,8 @@ quux
""" a 1 b 2 c 3
quux
""",
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -486,14 +554,18 @@ quux
""" a 1 b 2 c 3
quux
""",
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
fun testDeleteCharVisualBlockOnLastCharOfLine() {
doTest(
listOf("<C-V>", "x"),
"fo${c}o\n", "fo\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
"fo${c}o\n",
"fo\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -503,7 +575,10 @@ quux
}
doTest(
listOf("<C-V>", "j", "x"),
"\n\n", "\n\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
"\n\n",
"\n\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -523,7 +598,8 @@ quux
br
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -544,7 +620,8 @@ quux
br
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -555,7 +632,7 @@ quux
foo
bar
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("<C-V>" + "j" + "x"))
assertState(
@ -563,7 +640,7 @@ quux
oo
ar
""".trimIndent()
""".trimIndent(),
)
}
@ -598,7 +675,8 @@ quux
ZZZZZz
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -613,7 +691,8 @@ foobaz
bar
foobaz
""",
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -629,7 +708,8 @@ foobaz
r
foobaz
""",
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -642,7 +722,10 @@ foobaz
fun testReplaceMultipleCharsWithTextWithCount() {
doTest(
"3sxy<Esc>",
"fo${c}obar\n", "fox${c}yr\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
"fo${c}obar\n",
"fox${c}yr\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -660,7 +743,8 @@ foobaz
biff
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -674,7 +758,10 @@ foobaz
fun testReplaceModeSwitchToInsertModeAndBack() {
doTest(
"RXXX<Ins>YYY<Ins>ZZZ<Esc>",
"aaa${c}bbbcccddd\n", "aaaXXXYYYZZ${c}Zddd\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
"aaa${c}bbbcccddd\n",
"aaaXXXYYYZZ${c}Zddd\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -683,8 +770,10 @@ foobaz
fun testInsertModeSwitchToReplaceModeAndBack() {
doTest(
"iXXX<Ins>YYY<Ins>ZZZ<Esc>",
"aaa${c}bbbcccddd\n", "aaaXXXYYYZZ${c}Zcccddd\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
"aaa${c}bbbcccddd\n",
"aaaXXXYYYZZ${c}Zcccddd\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -703,7 +792,8 @@ foobaz
fo${c}o quux
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -715,7 +805,7 @@ foobaz
class C $c{
}
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("o" + "foo(\"<Right>, \"<Right><Right>;" + "<Esc>" + "."))
assertState(
@ -723,7 +813,7 @@ foobaz
foo("", "");
foo("", "");
}
"""
""",
)
}
@ -735,7 +825,7 @@ foobaz
class C $c{
}
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("o" + "C(" + "<BS>" + "(int i) {}" + "<Esc>" + "."))
assertState(
@ -743,7 +833,7 @@ foobaz
C(int i) {}
C(int i) {}
}
"""
""",
)
}
@ -755,7 +845,7 @@ foobaz
- 2
- 3
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("d$" + "j" + "."))
assertState(
@ -764,7 +854,7 @@ foobaz
- 3
""".trimIndent()
""".trimIndent(),
)
}
@ -776,7 +866,7 @@ foobaz
class C $c{
}
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("o" + "C(" + "<BS>" + "(int i) {" + "<Enter>" + "i = 3;" + "<Esc>" + "<Down>" + "."))
assertState(
@ -788,7 +878,7 @@ foobaz
i = 3;
}
}
"""
""",
)
}
@ -802,7 +892,7 @@ foobaz
- 2
- 3
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("A" + "<BS>" + "<Esc>" + "j" + "."))
assertState(
@ -811,7 +901,7 @@ foobaz
-
- 3
""".trimIndent()
""".trimIndent(),
)
// Case 2
@ -821,7 +911,7 @@ foobaz
- 2
- 3
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("A" + "4" + "<BS>" + "<Esc>" + "j" + "."))
assertState(
@ -830,7 +920,7 @@ foobaz
- 2
- 3
""".trimIndent()
""".trimIndent(),
)
// Case 3
@ -840,7 +930,7 @@ foobaz
- 2
- 3
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("A" + "<BS>" + "4" + "<Esc>" + "j" + "."))
assertState(
@ -849,7 +939,7 @@ foobaz
- 4
- 3
""".trimIndent()
""".trimIndent(),
)
}
@ -861,7 +951,7 @@ foobaz
* a little more text
* and final fold
*/
and some text after"""
and some text after""",
)
typeText(injector.parser.parseKeys("zc" + "G" + "O"))
assertState(
@ -871,7 +961,7 @@ and some text after"""
* and final fold
*/
$c
and some text after"""
and some text after""",
)
}
@ -886,7 +976,7 @@ and some text after"""
* and final fold
*/
and some text after
""".trimIndent()
""".trimIndent(),
)
myFixture.editor.foldingModel.runBatchFoldingOperation {
@ -904,14 +994,17 @@ and some text after"""
*/
$c
and some text after
""".trimIndent()
""".trimIndent(),
)
}
fun testRepeatChangeWordDoesNotBreakNextRepeatFind() {
doTest(
"fXcfYPATATA<Esc>fX.;.", "${c}aaaaXBBBBYaaaaaaaXBBBBYaaaaaaXBBBBYaaaaaaaa\n",
"aaaaPATATAaaaaaaaPATATAaaaaaaPATATAaaaaaaaa\n", VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
"fXcfYPATATA<Esc>fX.;.",
"${c}aaaaXBBBBYaaaaaaaXBBBBYaaaaaaXBBBBYaaaaaaaa\n",
"aaaaPATATAaaaaaaaPATATAaaaaaaPATATAaaaaaaaa\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -936,7 +1029,7 @@ and some text after"""
${c}lorem ipsum dolor sit amet
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -952,7 +1045,7 @@ and some text after"""
${c}lorem ipsum dolor sit amet
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -968,7 +1061,7 @@ and some text after"""
${c}lorem ipsum dolor sit amet
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -984,7 +1077,7 @@ and some text after"""
${c}lorem ipsum dolor sit amet
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -1000,7 +1093,7 @@ and some text after"""
psum dolor sit amet
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -1016,7 +1109,7 @@ and some text after"""
ipsum dolor sit amet
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -1034,7 +1127,8 @@ and some text after"""
${c}lorem ipsum dolor sit amet
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -1053,7 +1147,8 @@ and some text after"""
gaganis ${c}gaganis gaganis
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -1069,7 +1164,8 @@ and some text after"""
line 1
${c}line 3
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
}

View File

@ -34,15 +34,21 @@ class ChangeNumberActionTest : VimTestCase() {
fun testIncrementOctal() {
doTest(
Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "0477", "0500", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"),
"0477",
"0500",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
fun testDecrementOctal() {
doTest(
Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"), "010", "007", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"),
"010",
"007",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -65,16 +71,22 @@ class ChangeNumberActionTest : VimTestCase() {
fun testIncrementNegativeOctal() {
// Minus isn't processed
doTest(
Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "-0477", "-0500", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"),
"-0477",
"-0500",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
fun testDecrementNegativeOctal() {
// Minus isn't processed
doTest(
Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"), "-010", "-007", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
Lists.newArrayList(":set nf=octal<Enter>", "<C-X>"),
"-010",
"-007",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -100,50 +112,71 @@ class ChangeNumberActionTest : VimTestCase() {
fun testIncrementAlphaWithNumberFormatAlpha() {
doTest(
Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "foo", "goo", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"),
"foo",
"goo",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
fun testIncrementZWithNumberFormatAlpha() {
doTest(
Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "zzz", "zzz", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"),
"zzz",
"zzz",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
fun testIncrementXInHexNumberWithNumberFormatAlphaButNotHex() {
doTest(
Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"), "0<caret>x1", "0y1", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
Lists.newArrayList(":set nf=alpha<Enter>", "<C-A>"),
"0<caret>x1",
"0y1",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
fun testIncrementXInHexNumberWithNumberFormatHexAlpha() {
doTest(
Lists.newArrayList(":set nf=alpha,hex<Enter>", "<C-A>"), "0<caret>x1", "0x2", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
Lists.newArrayList(":set nf=alpha,hex<Enter>", "<C-A>"),
"0<caret>x1",
"0x2",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
fun testIncrementHexNumberWithoutNumberFormatHex() {
doTest(
Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"), "0x42", "1x42", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
Lists.newArrayList(":set nf=octal<Enter>", "<C-A>"),
"0x42",
"1x42",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
fun testIncrementOctalNumberWithoutNumberFormatOctal() {
doTest(
Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"), "077", "078", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"),
"077",
"078",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
fun testIncrementNegativeOctalNumberWithoutNumberFormatOctal() {
doTest(
Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"), "-077", "-076", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
Lists.newArrayList(":set nf=hex<Enter>", "<C-A>"),
"-077",
"-076",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -157,8 +190,11 @@ class ChangeNumberActionTest : VimTestCase() {
fun testIncrementLocatesNumberOnTheSameLine() {
doTest(
"<C-A>", "foo ->* bar 123\n", "foo ->* bar 12<caret>4\n", VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
"<C-A>",
"foo ->* bar 123\n",
"foo ->* bar 12<caret>4\n",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
}

View File

@ -34,7 +34,7 @@ class CopyActionTest : VimTestCase() {
tw<caret>o
three
""".trimIndent()
""".trimIndent(),
)
assertState(
"""
@ -43,7 +43,7 @@ class CopyActionTest : VimTestCase() {
two
three
""".trimIndent()
""".trimIndent(),
)
}
@ -56,7 +56,7 @@ class CopyActionTest : VimTestCase() {
bar
""".trimIndent()
""".trimIndent(),
)
assertState(
"""
@ -64,7 +64,7 @@ class CopyActionTest : VimTestCase() {
foo
bar
""".trimIndent()
""".trimIndent(),
)
}
@ -76,7 +76,7 @@ class CopyActionTest : VimTestCase() {
one two
<caret>three four
""".trimIndent()
""".trimIndent(),
)
assertState(
"""
@ -84,7 +84,7 @@ class CopyActionTest : VimTestCase() {
three four
three four
""".trimIndent()
""".trimIndent(),
)
}
@ -128,7 +128,7 @@ class CopyActionTest : VimTestCase() {
three
four
""".trimIndent()
""".trimIndent(),
)
assertPluginError(true)
}
@ -142,7 +142,7 @@ class CopyActionTest : VimTestCase() {
three
four
""".trimIndent()
""".trimIndent(),
)
assertPluginError(false)
assertState(
@ -152,7 +152,7 @@ class CopyActionTest : VimTestCase() {
three
four
""".trimIndent()
""".trimIndent(),
)
}
@ -164,7 +164,7 @@ class CopyActionTest : VimTestCase() {
three
four
""".trimIndent()
""".trimIndent(),
)
assertEquals(0, editor.caretModel.offset)
}
@ -177,7 +177,7 @@ class CopyActionTest : VimTestCase() {
<caret>* one
* two
""".trimIndent()
""".trimIndent(),
)
// XXX:
@ -192,7 +192,7 @@ class CopyActionTest : VimTestCase() {
* * one
* * two
""".trimIndent()
""".trimIndent(),
)
assertSelection(null)
assertOffset(2)
@ -206,7 +206,7 @@ class CopyActionTest : VimTestCase() {
<caret>foo
bar
""".trimIndent()
""".trimIndent(),
)
assertOffset(0)
assertMode(VimStateMachine.Mode.COMMAND)
@ -223,7 +223,7 @@ class CopyActionTest : VimTestCase() {
<caret>bar
baz
""".trimIndent()
""".trimIndent(),
)
assertEquals('\"', VimPlugin.getRegister().defaultRegister)
enterCommand("set clipboard=unnamed")
@ -248,7 +248,7 @@ class CopyActionTest : VimTestCase() {
foo
<caret>foo
""".trimIndent()
""".trimIndent(),
)
}
@ -263,7 +263,7 @@ class CopyActionTest : VimTestCase() {
bar
baz
""".trimIndent()
""".trimIndent(),
)
typeText("<C-V>j" + "\"*y" + "\"*p")
val register = VimPlugin.getRegister().getRegister('*')
@ -273,7 +273,7 @@ class CopyActionTest : VimTestCase() {
f
b
""".trimIndent(),
register!!.text
register!!.text,
)
assertState(
"""
@ -281,7 +281,7 @@ class CopyActionTest : VimTestCase() {
bbar
baz
""".trimIndent()
""".trimIndent(),
)
}
@ -301,7 +301,7 @@ class CopyActionTest : VimTestCase() {
<b></b>
</root>
""".trimIndent()
""".trimIndent(),
)
typeText("dit", "j", "cit", "<C-R>\"")
assertState(
@ -311,7 +311,7 @@ class CopyActionTest : VimTestCase() {
<b>value</b>
</root>
""".trimIndent()
""".trimIndent(),
)
}
}

View File

@ -34,7 +34,7 @@ class GuardedBlocksTest : VimTestCase() {
[1234567890
]123${c}4567890[
1234567890]
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("dd"))
assertState(
@ -42,7 +42,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
$c
1234567890
""".trimIndent()
""".trimIndent(),
)
}
@ -88,7 +88,7 @@ class GuardedBlocksTest : VimTestCase() {
[123${c}4567890
]123456789[0
1234567890]
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("dd"))
assertState(
@ -96,7 +96,7 @@ class GuardedBlocksTest : VimTestCase() {
123${c}4567890
1234567890
1234567890
""".trimIndent()
""".trimIndent(),
)
}
@ -107,7 +107,7 @@ class GuardedBlocksTest : VimTestCase() {
[1234567890
]123456789[0
123456${c}7890]
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("dd"))
assertState(
@ -115,7 +115,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
1234567890
123456${c}7890
""".trimIndent()
""".trimIndent(),
)
}
@ -126,7 +126,7 @@ class GuardedBlocksTest : VimTestCase() {
[1234567890
]123${c}4567890[
1234567890]
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("cc"))
assertState(
@ -134,7 +134,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
$c
1234567890
""".trimIndent()
""".trimIndent(),
)
assertMode(VimStateMachine.Mode.INSERT)
}
@ -146,7 +146,7 @@ class GuardedBlocksTest : VimTestCase() {
[1234567890
]123${c}4567890[
1234567890]
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("O"))
assertState(
@ -155,7 +155,7 @@ class GuardedBlocksTest : VimTestCase() {
$c
1234567890
1234567890
""".trimIndent()
""".trimIndent(),
)
assertMode(VimStateMachine.Mode.INSERT)
}
@ -167,7 +167,7 @@ class GuardedBlocksTest : VimTestCase() {
[1234567890
]123${c}4567890[
1234567890]
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("o"))
assertState(
@ -176,7 +176,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
$c
1234567890
""".trimIndent()
""".trimIndent(),
)
assertMode(VimStateMachine.Mode.INSERT)
}
@ -223,14 +223,14 @@ class GuardedBlocksTest : VimTestCase() {
"""
[1234567890
]12345${c}67890
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("cc"))
assertState(
"""
1234567890
$c
""".trimIndent()
""".trimIndent(),
)
assertMode(VimStateMachine.Mode.INSERT)
}
@ -241,14 +241,14 @@ class GuardedBlocksTest : VimTestCase() {
"""
123456${c}7890[
1234567890]
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("dd"))
assertState(
"""
$c
1234567890
""".trimIndent()
""".trimIndent(),
)
assertMode(VimStateMachine.Mode.COMMAND)
}
@ -260,14 +260,14 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
123456${c}7890[
1234567890]
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("dd"))
assertState(
"""
${c}1234567890
1234567890
""".trimIndent()
""".trimIndent(),
)
assertMode(VimStateMachine.Mode.COMMAND)
}
@ -279,7 +279,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
123456${c}7890[
1234567890]
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("cc"))
assertState(
@ -287,7 +287,7 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
$c
1234567890
""".trimIndent()
""".trimIndent(),
)
assertMode(VimStateMachine.Mode.INSERT)
}
@ -299,14 +299,14 @@ class GuardedBlocksTest : VimTestCase() {
1234567890
$c[
1234567890]
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("dd"))
assertState(
"""
1234567890
1234567890
""".trimIndent()
""".trimIndent(),
)
assertMode(VimStateMachine.Mode.COMMAND)
}

View File

@ -163,7 +163,7 @@ class MacroActionTest : VimTestCase() {
1all rocks and lavender and tufted grass,
1where it was settled on some sodden sand
${c}1hard by the torrent of a mountain pass.
""".trimIndent()
""".trimIndent(),
)
}
}

View File

@ -26,7 +26,7 @@ class MarkTest : VimTestCase() {
""" foo
ba<caret>r
baz
"""
""",
)
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'a')
@ -42,7 +42,7 @@ class MarkTest : VimTestCase() {
""" foo
ba<caret>r
baz
"""
""",
)
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'G')
@ -58,7 +58,7 @@ class MarkTest : VimTestCase() {
""" foo
ba<caret>r
baz
"""
""",
)
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'x')
@ -74,7 +74,7 @@ class MarkTest : VimTestCase() {
<caret>0
bar
""".trimIndent()
""".trimIndent(),
)
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'a')
@ -88,7 +88,7 @@ class MarkTest : VimTestCase() {
""" foo
ba<caret>r
baz
"""
""",
)
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'a')
@ -102,7 +102,7 @@ class MarkTest : VimTestCase() {
""" foo
bar
ba<caret>z
"""
""",
)
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'x')
@ -118,7 +118,7 @@ class MarkTest : VimTestCase() {
""" foo
bar
ba<caret>z
"""
""",
)
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'x')
@ -136,7 +136,7 @@ class MarkTest : VimTestCase() {
ba<caret>r
baz
""".trimIndent()
""".trimIndent(),
)
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'Y')
@ -157,7 +157,7 @@ class MarkTest : VimTestCase() {
""" foo
ba<caret>r
baz
"""
""",
)
val vimEditor: VimEditor = IjVimEditor(myFixture.editor)
val mark = injector.markService.getMark(vimEditor.primaryCaret(), 'Y')
@ -178,7 +178,7 @@ class MarkTest : VimTestCase() {
""" foo
bar
baz
"""
""",
)
assertOffset(6)
}
@ -190,7 +190,7 @@ class MarkTest : VimTestCase() {
""" foo
bar
baz
"""
""",
)
assertOffset(4)
}
@ -203,13 +203,13 @@ class MarkTest : VimTestCase() {
efgh
ij<caret>kl
mnop
"""
""",
)
assertState(
""" abcd
ekl
mnop
"""
""",
)
}
@ -221,12 +221,12 @@ class MarkTest : VimTestCase() {
efgh
ij<caret>kl
mnop
"""
""",
)
assertState(
""" abcd
mnop
"""
""",
)
}
@ -240,7 +240,7 @@ class MarkTest : VimTestCase() {
<caret>hello world
three four
""".trimIndent()
""".trimIndent(),
)
assertOffset(13)
}
@ -254,7 +254,7 @@ class MarkTest : VimTestCase() {
<caret>three
four five
""".trimIndent()
""".trimIndent(),
)
assertOffset(14)
}
@ -275,7 +275,8 @@ class MarkTest : VimTestCase() {
four five
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
@ -298,8 +299,8 @@ class MarkTest : VimTestCase() {
assertOffset(7)
}
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT, "This test freezes")
// we change start mark, but actually the start and end has changed
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT, "This test freezes")
fun testChangeSelectionStartMarkToBelowPosition() {
configureByText("lala\nl<caret>alala\nlala\n")
typeText(injector.parser.parseKeys("v3l<Esc>"))
@ -427,7 +428,7 @@ class MarkTest : VimTestCase() {
For example: homework, homework, homework, homework, homework, homework, homework, homework, homework.
See, nothing.
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("Vj<Esc>"))
typeText(injector.parser.parseKeys("`<"))
@ -444,7 +445,7 @@ class MarkTest : VimTestCase() {
For example: homework, homework, homework, homework, <caret>homework, homework, homework, homework, homework.
See, nothing.
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys("Vk<Esc>"))
typeText(injector.parser.parseKeys("`<"))
@ -461,7 +462,7 @@ class MarkTest : VimTestCase() {
For example: homework, homework, homework, homework, <caret>homework, homework, homework, homework, homework.
See, nothing.
""".trimIndent()
""".trimIndent(),
)
typeText("ma$")
assertState(
@ -471,7 +472,7 @@ class MarkTest : VimTestCase() {
For example: homework, homework, homework, homework, homework, homework, homework, homework, homework<caret>.
See, nothing.
""".trimIndent()
""".trimIndent(),
)
typeText("`a")
assertState(
@ -481,7 +482,7 @@ class MarkTest : VimTestCase() {
For example: homework, homework, homework, homework, <caret>homework, homework, homework, homework, homework.
See, nothing.
""".trimIndent()
""".trimIndent(),
)
}
@ -493,7 +494,7 @@ class MarkTest : VimTestCase() {
For example: homework, homework, homework, homework, <caret>homework, homework, homework, homework, homework.
See, nothing.
""".trimIndent()
""".trimIndent(),
)
typeText("vey\$p")
assertState(
@ -503,7 +504,7 @@ class MarkTest : VimTestCase() {
For example: homework, homework, homework, homework, homework, homework, homework, homework, homework.homework
See, nothing.
""".trimIndent()
""".trimIndent(),
)
typeText("gv")
assertState(
@ -513,7 +514,7 @@ class MarkTest : VimTestCase() {
For example: homework, homework, homework, homework, <selection>homewor<caret>k</selection>, homework, homework, homework, homework.homework
See, nothing.
""".trimIndent()
""".trimIndent(),
)
}
}

View File

@ -33,7 +33,7 @@ class MotionActionTest : VimTestCase() {
fileContents,
"one ${s}two${se}\n",
VimStateMachine.Mode.VISUAL,
VimStateMachine.SubMode.VISUAL_CHARACTER
VimStateMachine.SubMode.VISUAL_CHARACTER,
)
}
@ -211,7 +211,7 @@ class MotionActionTest : VimTestCase() {
"""foo {
${c}bar
}
"""
""",
)
assertState(
"""
@ -219,7 +219,7 @@ class MotionActionTest : VimTestCase() {
}
""".trimIndent()
""".trimIndent(),
)
assertOffset(6)
}
@ -624,7 +624,7 @@ class MotionActionTest : VimTestCase() {
foo(bar, foo(bar, ${c}baz
bar(foo)
""".trimIndent()
""".trimIndent(),
)
assertOffset(12)
}
@ -636,7 +636,7 @@ class MotionActionTest : VimTestCase() {
"""foo {
bar,
b${c}az
"""
""",
)
assertOffset(4)
}
@ -647,7 +647,7 @@ class MotionActionTest : VimTestCase() {
injector.parser.parseKeys("])"),
"""foo(bar, ${c}baz,
quux)
"""
""",
)
assertOffset(21)
}
@ -787,7 +787,7 @@ class MotionActionTest : VimTestCase() {
two
""".trimIndent()
""".trimIndent(),
)
assertOffset(4)
}
@ -799,7 +799,7 @@ class MotionActionTest : VimTestCase() {
"""${c}one
two
"""
""",
)
assertOffset(6)
}
@ -830,7 +830,7 @@ two
${c}one
""".trimIndent()
""".trimIndent(),
)
assertOffset(4)
}
@ -846,7 +846,7 @@ two
two
three
""".trimIndent()
""".trimIndent(),
)
assertOffset(4)
}
@ -936,7 +936,7 @@ two
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -959,7 +959,7 @@ two
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -992,7 +992,7 @@ two
bar
baz
""".trimIndent()
""".trimIndent(),
)
assertSelection(
"""
@ -1000,7 +1000,7 @@ two
bar
baz
""".trimIndent()
""".trimIndent(),
)
typeText(injector.parser.parseKeys(">"))
assertMode(VimStateMachine.Mode.COMMAND)
@ -1008,14 +1008,14 @@ two
""" foo
bar
baz
"""
""",
)
typeText(injector.parser.parseKeys("gv"))
assertSelection(
""" foo
bar
baz
"""
""",
)
typeText(injector.parser.parseKeys(">"))
assertMode(VimStateMachine.Mode.COMMAND)
@ -1023,14 +1023,14 @@ two
""" foo
bar
baz
"""
""",
)
typeText(injector.parser.parseKeys("gv"))
assertSelection(
""" foo
bar
baz
"""
""",
)
}
@ -1059,7 +1059,7 @@ two
baz
quux
""".trimIndent()
""".trimIndent(),
)
assertMode(VimStateMachine.Mode.VISUAL)
assertSelection(
@ -1067,7 +1067,7 @@ two
bar
baz
""".trimIndent()
""".trimIndent(),
)
assertOffset(8)
}
@ -1082,7 +1082,7 @@ two
${c}baz
quux
""".trimIndent()
""".trimIndent(),
)
assertMode(VimStateMachine.Mode.VISUAL)
assertSelection(
@ -1090,7 +1090,7 @@ two
bar
baz
""".trimIndent()
""".trimIndent(),
)
assertOffset(4)
}

View File

@ -56,7 +56,7 @@ class ReformatCodeTest : VimTestCase() {
int b;
int c;
}
"""
""",
)
}

View File

@ -29,14 +29,14 @@ class RepeatActionTest : VimTestCase() {
"The first line.\n" +
"This is the second line.\n" +
"Third line here, with a comma.\n" +
"Last line."
"Last line.",
)
typeText(injector.parser.parseKeys("j" + "ct." + "Change the line to point" + "<Esc>" + "j0" + "."))
assertState(
"The first line.\n" +
"Change the line to point.\n" +
"Change the line to point.\n" +
"Last line."
"Last line.",
)
}
@ -57,14 +57,14 @@ class RepeatActionTest : VimTestCase() {
"There is a red house.\n" +
"Another red house there.\n" +
"They have red windows.\n" +
"Good."
"Good.",
)
typeText(injector.parser.parseKeys("www" + "<C-V>ec" + "blue" + "<Esc>" + "j0w." + "j0ww."))
assertState(
"There is a blue house.\n" +
"Another blue house there.\n" +
"They have blue windows.\n" +
"Good."
"Good.",
)
}
}

View File

@ -195,7 +195,7 @@ class RepeatChangeActionTest : VimTestCase() {
| all rocks and lavender and tufted grass,
| where it was settled on some sodden sand
| hard by the torrent of a mountain pass.
""".trimMargin()
""".trimMargin()
val after = """
|A Discovery
|
@ -203,7 +203,7 @@ class RepeatChangeActionTest : VimTestCase() {
|all rocks and lavender and tufted grass,
|where it was settled on some sodden sand
|hard by the torrent of a mountain pass.
""".trimMargin()
""".trimMargin()
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
@ -238,7 +238,7 @@ class RepeatChangeActionTest : VimTestCase() {
XXXXX it was settled on some sodden sand
hard ${c}XXXXXe torrent of a mountain pass.
"""
""",
)
fun `test block motion to end`() {
val keys = listOf("<C-V>jjerXjl", ".")
@ -312,7 +312,7 @@ class RepeatChangeActionTest : VimTestCase() {
Three
Two
One
"""
""",
)
fun `test redo register feature`() {
doTest(
@ -328,7 +328,8 @@ class RepeatChangeActionTest : VimTestCase() {
One
""".trimIndent(),
VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE,
)
}
}

View File

@ -37,7 +37,8 @@ class ChangeLineActionTest : VimTestCase() {
I found it in a legendary land
$c
""".trimIndent(),
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -54,7 +55,8 @@ class ChangeLineActionTest : VimTestCase() {
$c
""".trimIndent(),
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -69,7 +71,8 @@ class ChangeLineActionTest : VimTestCase() {
I found it in a legendary land
$c
""".trimIndent(),
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -86,7 +89,8 @@ class ChangeLineActionTest : VimTestCase() {
$c
""".trimIndent(),
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -101,7 +105,8 @@ class ChangeLineActionTest : VimTestCase() {
$c
all rocks and lavender and tufted grass,
""".trimIndent(),
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -118,7 +123,8 @@ class ChangeLineActionTest : VimTestCase() {
$c
""".trimIndent(),
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -135,7 +141,8 @@ class ChangeLineActionTest : VimTestCase() {
all rocks and lavender and tufted grass,
$c
""".trimIndent(),
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -172,7 +179,8 @@ class ChangeLineActionTest : VimTestCase() {
that priceless mote now dimpling the convex
and limpid teardrop on a lighted slide.
""".trimIndent(),
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
}

View File

@ -29,7 +29,9 @@ class ChangeMotionActionTest : VimTestCase() {
doTest(
"cc",
"foo\n" + "${c}bar\n",
"foo\n${c}" + "\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
"foo\n${c}" + "\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -47,7 +49,8 @@ class ChangeMotionActionTest : VimTestCase() {
....${c}
}
""".trimIndent().dotToSpace(),
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -56,7 +59,9 @@ class ChangeMotionActionTest : VimTestCase() {
doTest(
"ccbaz",
"${c}foo\n" + "bar\n",
"baz\n" + "bar\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
"baz\n" + "bar\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -73,7 +78,8 @@ class ChangeMotionActionTest : VimTestCase() {
${c}
""".trimIndent(),
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -81,23 +87,31 @@ class ChangeMotionActionTest : VimTestCase() {
doTest(
"c_baz",
"${c}foo\n" + "bar\n",
"baz\n" + "bar\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
"baz\n" + "bar\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
// VIM-200 |c| |w|
fun testChangeWordAtLastChar() {
doTest(
"cw", "on${c}e two three\n", "on${c} two three\n", VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE
"cw",
"on${c}e two three\n",
"on${c} two three\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
// VIM-1380 |c| |w| |count|
fun testChangeTwoWordsAtLastChar() {
doTest(
"c2w", "on${c}e two three\n", "on${c} three\n", VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE
"c2w",
"on${c}e two three\n",
"on${c} three\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -115,15 +129,19 @@ class ChangeMotionActionTest : VimTestCase() {
}
""".trimIndent(),
VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
// VIM-276 |c| |T|
fun testChangeLinesTillBackwards() {
doTest(
"cT(", "if (condition) ${c}{\n" + "}\n", "if ({\n" + "}\n", VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE
"cT(",
"if (condition) ${c}{\n" + "}\n",
"if ({\n" + "}\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -133,7 +151,9 @@ class ChangeMotionActionTest : VimTestCase() {
doTest(
"cFc",
"if (condition) {${c}\n" + "}\n",
"if (\n" + "}\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
"if (\n" + "}\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -141,7 +161,10 @@ class ChangeMotionActionTest : VimTestCase() {
fun testChangeLastWordInLine() {
doTest(
"cw",
"ab.${c}cd\n", "ab.${c}\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
"ab.${c}cd\n",
"ab.${c}\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}
@ -149,7 +172,10 @@ class ChangeMotionActionTest : VimTestCase() {
fun testChangeLastInnerWordInLine() {
doTest(
listOf("c", "iw", "baz"),
"foo bar bo${c}o\n", "foo bar baz\n", VimStateMachine.Mode.INSERT, VimStateMachine.SubMode.NONE
"foo bar bo${c}o\n",
"foo bar baz\n",
VimStateMachine.Mode.INSERT,
VimStateMachine.SubMode.NONE,
)
}

View File

@ -64,7 +64,7 @@ class ChangeVisualActionTest : VimTestCase() {
all rocks and lavender and tufted grass,
${c}
"""
""",
)
fun `test multiple line change till the end`() {
val keys = "Vjc"
@ -146,7 +146,7 @@ class ChangeVisualActionTest : VimTestCase() {
fun `test change visual action`() {
typeTextInFile(
injector.parser.parseKeys("v2lc" + "aaa" + "<ESC>"),
"abcd${c}ffffff${c}abcde${c}aaaa\n"
"abcd${c}ffffff${c}abcde${c}aaaa\n",
)
assertMode(VimStateMachine.Mode.COMMAND)
assertState("abcdaa${c}afffaa${c}adeaa${c}aa\n")
@ -170,7 +170,7 @@ class ChangeVisualActionTest : VimTestCase() {
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -192,7 +192,7 @@ class ChangeVisualActionTest : VimTestCase() {
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
}

View File

@ -67,7 +67,7 @@ class ChangeVisualLinesEndActionTest : VimTestCase() {
all rocks and lavender and tufted grass,
where it was settled on some sodden sand
${c}
"""
""",
)
fun `test change last two lines`() {
val keys = "vjC"

View File

@ -26,7 +26,7 @@ class ChangeNumberDecActionTest : VimTestCase() {
"00000",
"01777777777777777777777",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -40,7 +40,7 @@ class ChangeNumberDecActionTest : VimTestCase() {
"00005",
"01777777777777777777773",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
}

View File

@ -29,7 +29,7 @@ class ChangeVisualNumberAvalancheDecActionTest : VimTestCase() {
number 1
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -47,7 +47,7 @@ class ChangeVisualNumberAvalancheDecActionTest : VimTestCase() {
number 1
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
}

View File

@ -29,7 +29,7 @@ class ChangeVisualNumberAvalancheIncActionTest : VimTestCase() {
number 4
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -47,7 +47,7 @@ class ChangeVisualNumberAvalancheIncActionTest : VimTestCase() {
number 7
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
}

View File

@ -22,7 +22,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
"${c}12345",
"${c}12344",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -32,7 +32,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
"11 <- should not be decremented |${c}11| should not be decremented -> 12",
"11 <- should not be decremented |${c}10| should not be decremented -> 12",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -42,7 +42,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
"11111${c}33333111111",
"11111${c}33332111111",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -70,7 +70,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -88,7 +88,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
999
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -98,7 +98,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
"1 should$c not be decremented -> 2",
"${c}0 should not be decremented -> 2",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -111,7 +111,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
3
${c}4
5
""".trimIndent()
""".trimIndent(),
)
assertState(
"""
@ -120,7 +120,7 @@ class ChangeVisualNumberDecActionTest : VimTestCase() {
3
${c}3
4
""".trimIndent()
""".trimIndent(),
)
}
}

View File

@ -22,7 +22,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"${c}12345",
"${c}12346",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -32,7 +32,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"11 <- should not be incremented |${c}11| should not be incremented -> 12",
"11 <- should not be incremented |${c}12| should not be incremented -> 12",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -42,7 +42,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"11111${c}22222111111",
"11111${c}22223111111",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -70,7 +70,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -88,7 +88,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
1000
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -98,7 +98,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"1 should$c not be incremented -> 2",
"${c}2 should not be incremented -> 2",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -111,7 +111,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
3
${c}4
5
""".trimIndent()
""".trimIndent(),
)
assertState(
"""
@ -120,7 +120,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
3
${c}5
6
""".trimIndent()
""".trimIndent(),
)
}
@ -130,7 +130,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
"1 <- should$c not be incremented 2",
"1 <- should$c not be incremented 3",
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -144,7 +144,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|2 should not be incremented -> 2
""".trimMargin(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -160,7 +160,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|2 should not be incremented -> 2
""".trimMargin(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -178,7 +178,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|1 <- should not be incremented -> 2
""".trimMargin(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -196,7 +196,7 @@ class ChangeVisualNumberIncActionTest : VimTestCase() {
|1 <- should not be incremented 3
""".trimMargin(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
}

View File

@ -28,7 +28,7 @@ class DeleteEndOfLineActionTest : VimTestCase() {
all rocks and lavender and tufted grass,
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
}

View File

@ -38,7 +38,7 @@ class DeleteJoinLinesSpacesActionTest : VimOptionTestCase(IjOptionConstants.idea
hard by the torrent of a mountain pass.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -61,7 +61,7 @@ class DeleteJoinLinesSpacesActionTest : VimOptionTestCase(IjOptionConstants.idea
hard by the torrent of a mountain pass.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -87,7 +87,7 @@ class DeleteJoinLinesSpacesActionTest : VimOptionTestCase(IjOptionConstants.idea
hard by the torrent of a mountain pass.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
}

View File

@ -39,7 +39,7 @@ class DeleteJoinVisualLinesSpacesActionTest : VimOptionTestCase(IjOptionConstant
hard by the torrent of a mountain pass.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
}

View File

@ -25,13 +25,13 @@ class DeleteMotionActionTest : VimTestCase() {
def xxx():
expression one
expression${c} two
""".trimIndent()
""".trimIndent(),
)
assertState(
"""
def xxx():
${c}expression one
""".trimIndent()
""".trimIndent(),
)
}
@ -42,13 +42,13 @@ class DeleteMotionActionTest : VimTestCase() {
def xxx():
expression${c} one
expression two
""".trimIndent()
""".trimIndent(),
)
assertState(
"""
def xxx():
${c}expression two
""".trimIndent()
""".trimIndent(),
)
}
@ -57,7 +57,7 @@ class DeleteMotionActionTest : VimTestCase() {
"dd",
"""
def x${c}xx():
""".trimIndent()
""".trimIndent(),
)
assertState(c)
}
@ -69,7 +69,7 @@ class DeleteMotionActionTest : VimTestCase() {
|def xxx():
| expression one
| expression${c} two
""".trimMargin()
""".trimMargin(),
)
enterCommand("set nostartofline")
typeText("dd")
@ -77,7 +77,7 @@ class DeleteMotionActionTest : VimTestCase() {
"""
|def xxx():
| expression${c} one
""".trimMargin()
""".trimMargin(),
)
}
@ -89,7 +89,7 @@ class DeleteMotionActionTest : VimTestCase() {
def xxx():
expression one
expression${c} two
""".trimIndent()
""".trimIndent(),
)
val savedText = VimPlugin.getRegister().lastRegister?.text ?: ""
assertEquals(" expression two\n", savedText)
@ -107,7 +107,7 @@ class DeleteMotionActionTest : VimTestCase() {
abcde
abcde
""".trimIndent()
""".trimIndent(),
)
assertState("${c}abcde\n${c}")
}
@ -126,7 +126,7 @@ class DeleteMotionActionTest : VimTestCase() {
| }
| }
|}
""".trimMargin()
""".trimMargin(),
)
assertState(
"""|public class Foo {
@ -140,7 +140,7 @@ class DeleteMotionActionTest : VimTestCase() {
| }
| }
|}
""".trimMargin()
""".trimMargin(),
)
}
@ -179,7 +179,7 @@ class DeleteMotionActionTest : VimTestCase() {
I found it in a legendary land
${c}all rocks and lavender and tufted grass,
""".trimIndent()
""".trimIndent(),
)
}
@ -202,7 +202,7 @@ class DeleteMotionActionTest : VimTestCase() {
I found it in a legendary land
all rocks and lavender and tufted grass,
""".trimIndent()
""".trimIndent(),
)
}
}

View File

@ -116,7 +116,7 @@ class DeleteVisualActionTest : VimTestCase() {
all rocks ${c}and lavender and tufted grass,
where it was settled on some sodden sand
${se}hard by the torrent of a mountain pass.
""".trimIndent()
""".trimIndent(),
)
IdeaSelectionControl.controlNonVimSelectionChange(myFixture.editor)
waitAndAssertMode(myFixture, VimStateMachine.Mode.VISUAL)
@ -126,7 +126,7 @@ class DeleteVisualActionTest : VimTestCase() {
A Discovery
hard by the torrent of a mountain pass.
""".trimIndent()
""".trimIndent(),
)
assertState(VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}

View File

@ -29,7 +29,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
hard by the torrent of a mountain pass.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -48,7 +48,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
${c}where it was settled on some sodden sand
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -67,7 +67,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
hard by the torrent of a mountain pass.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}
@ -86,7 +86,7 @@ class DeleteVisualLinesActionTest : VimTestCase() {
${c}where it was settled on some sodden sand
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
}

View File

@ -56,7 +56,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
Yesterday it w${c}
Today it is not working
The test is like that.
""".trimIndent()
""".trimIndent(),
)
}
@ -74,7 +74,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
Yesterday it worke${c}
Today it is not working
The test is like that.
""".trimIndent()
""".trimIndent(),
)
}
@ -92,7 +92,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
Yesterday it worke${c}
Today it is not working
The test is like that.
""".trimIndent()
""".trimIndent(),
)
}
@ -304,7 +304,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
abcde
abcde
""".trimIndent()
""".trimIndent(),
)
assertState("${c}abcde\n${c}")
}
@ -494,7 +494,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
abcde
abcde
""".trimIndent()
""".trimIndent(),
)
assertState("${c}abcde\n${c}")
}
@ -644,7 +644,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
abcde
abcde
""".trimIndent()
""".trimIndent(),
)
assertState(
"""
@ -654,7 +654,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
a
abcde
""".trimIndent()
""".trimIndent(),
)
}
@ -673,7 +673,7 @@ class DeleteVisualLinesEndActionTest : VimOptionTestCase(OptionConstants.virtual
Today it is not working
The test is like that.
""".trimIndent(),
VimStateMachine.Mode.INSERT
VimStateMachine.Mode.INSERT,
)
}
}

View File

@ -20,14 +20,14 @@ class InsertAfterLineEndActionTest : VimTestCase() {
one two ${c}three
sev${c}en si${c}x five
""".trimIndent()
""".trimIndent(),
)
assertState(
"""
one two three fou${c}r
seven six five fou${c}r
""".trimIndent()
""".trimIndent(),
)
}
@ -51,7 +51,7 @@ class InsertAfterLineEndActionTest : VimTestCase() {
hard by the torrent of a mountain pass.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
assertMode(VimStateMachine.Mode.COMMAND)
}

View File

@ -32,7 +32,7 @@ class InsertBeforeFirstNonBlankActionTest : VimTestCase() {
hard by the torrent of a mountain pass.
""".trimIndent(),
VimStateMachine.Mode.COMMAND,
VimStateMachine.SubMode.NONE
VimStateMachine.SubMode.NONE,
)
assertMode(VimStateMachine.Mode.COMMAND)
}

Some files were not shown because too many files have changed in this diff Show More