mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-04 16:34:02 +02:00
Ktlint format
This commit is contained in:
parent
3ebaf38486
commit
0510fe8530
scripts/src/main/kotlin/scripts
src
main/java/com/maddyhome/idea/vim/extension/surround
test/java/org/jetbrains/plugins/ideavim/ex/implementation
vim-engine
build.gradle.kts
src/main/kotlin/com/maddyhome/idea/vim
KeyHandler.kt
action
change
UndoAction.kt
change
ChangeCaseLowerMotionAction.ktChangeCaseToggleMotionAction.ktChangeCaseUpperMotionAction.ktChangeLastSearchReplaceAction.ktChangeLineAction.ktChangeMotionAction.ktChangeVisualAction.ktChangeVisualLinesAction.ktChangeVisualLinesEndAction.kt
delete
DeleteCharacterAction.ktDeleteVisualAction.ktDeleteVisualLinesAction.ktDeleteVisualLinesEndAction.kt
insert
InsertCharacterAroundCursorAction.ktInsertDeleteInsertedTextAction.ktInsertNewLineBelowAction.ktInsertPreviousInsertAction.ktInsertRegisterAction.kt
shift
copy
motion
leftright
MotionArrowLeftAction.ktMotionArrowRightAction.ktMotionEndAction.ktMotionHomeAction.ktMotionLeftAction.ktMotionRightAction.ktTillCharacterMotion.kt
screen
scroll
MotionScrollFirstScreenLinePageStartAction.ktMotionScrollHalfWidthLeftAction.ktMotionScrollPageDownAction.ktMotionScrollPageUpAction.kt
text
updown
MotionArrowDownAction.ktMotionArrowUpAction.ktMotionGotoLineLastAction.ktMotionGotoLineLastEndAction.kt
visual
api
VimCaret.ktVimChangeGroup.ktVimChangeGroupBase.ktVimDigraphGroupBase.ktVimEditor.ktVimInjector.ktVimInjectorBase.ktVimKeyGroupBase.ktVimMarkServiceBase.ktVimMotionGroupBase.ktVimOptionGroup.ktVimOptionGroupBase.ktVimProcessGroup.ktVimSearchGroup.ktVimSearchHelperBase.ktVimStringParser.ktVimStringParserBase.kt
command
common
diagnostic
ex/ranges
group/visual
handler
ChangeEditorActionHandler.ktEditorActionHandlerBase.ktMotionActionHandler.ktVimActionHandler.ktVisualOperatorActionHandler.kt
history
key
macro
mark
options
put
regexp
@ -10,4 +10,4 @@ package scripts
|
||||
|
||||
fun main() {
|
||||
println("Hello")
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ fun httpClient(): HttpClient {
|
||||
Json {
|
||||
prettyPrint = true
|
||||
isLenient = true
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -215,10 +215,10 @@ internal class VimSurroundExtension : VimExtension {
|
||||
val searchHelper = injector.searchHelper
|
||||
return when (char) {
|
||||
't' -> searchHelper.findBlockTagRange(editor, caret, 1, true)
|
||||
'(', ')', 'b' -> searchHelper.findBlockRange(editor, caret, '(', 1,true)
|
||||
'[', ']' -> searchHelper.findBlockRange(editor, caret, '[', 1,true)
|
||||
'{', '}', 'B' -> searchHelper.findBlockRange(editor, caret, '{', 1,true)
|
||||
'<', '>' -> searchHelper.findBlockRange(editor, caret, '<', 1,true)
|
||||
'(', ')', 'b' -> searchHelper.findBlockRange(editor, caret, '(', 1, true)
|
||||
'[', ']' -> searchHelper.findBlockRange(editor, caret, '[', 1, true)
|
||||
'{', '}', 'B' -> searchHelper.findBlockRange(editor, caret, '{', 1, true)
|
||||
'<', '>' -> searchHelper.findBlockRange(editor, caret, '<', 1, true)
|
||||
'`', '\'', '"' -> {
|
||||
val caretOffset = caret.offset.point
|
||||
val text = editor.text()
|
||||
|
@ -10,7 +10,6 @@ package org.jetbrains.plugins.ideavim.ex.implementation
|
||||
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class LongerFunctionTest : VimTestCase() {
|
||||
@ -150,25 +149,33 @@ class LongerFunctionTest : VimTestCase() {
|
||||
|
||||
@Test
|
||||
fun `test invert function in normal mode`() {
|
||||
configureByText("""
|
||||
configureByText(
|
||||
"""
|
||||
val myValue = t${c}rue
|
||||
""")
|
||||
""",
|
||||
)
|
||||
injector.vimscriptExecutor.execute(invert)
|
||||
typeText("!")
|
||||
assertState("""
|
||||
assertState(
|
||||
"""
|
||||
val myValue = fals${c}e
|
||||
""")
|
||||
""",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test invert function in visual mode`() {
|
||||
configureByText("""
|
||||
configureByText(
|
||||
"""
|
||||
val my${c}StartOffset = 10
|
||||
""")
|
||||
""",
|
||||
)
|
||||
injector.vimscriptExecutor.execute(invert)
|
||||
typeText("vtO!")
|
||||
assertState("""
|
||||
assertState(
|
||||
"""
|
||||
val myEndOffset = 10
|
||||
""")
|
||||
""",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ tasks {
|
||||
|
||||
ktlint {
|
||||
disabledRules.add("no-wildcard-imports")
|
||||
version.set("0.43.0")
|
||||
version.set("0.48.2")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
@ -213,7 +213,9 @@ public class KeyHandler {
|
||||
): Node<VimActionsInitiator>? {
|
||||
return if (editorState.isDuplicateOperatorKeyStroke(key)) {
|
||||
editorState.commandBuilder.getChildNode(KeyStroke.getKeyStroke('_'))
|
||||
} else node
|
||||
} else {
|
||||
node
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleEditorReset(
|
||||
@ -235,7 +237,8 @@ public class KeyHandler {
|
||||
injector.actionExecutor.executeCommand(
|
||||
editor,
|
||||
{ executed[0] = injector.actionExecutor.executeEsc(context) },
|
||||
"", null
|
||||
"",
|
||||
null,
|
||||
)
|
||||
indicateError = !executed[0]!!
|
||||
}
|
||||
@ -287,7 +290,9 @@ public class KeyHandler {
|
||||
}
|
||||
return if (editorState.isRegisterPending) {
|
||||
true
|
||||
} else key.keyChar == '"' && !editorState.isOperatorPending && editorState.commandBuilder.expectedArgumentType == null
|
||||
} else {
|
||||
key.keyChar == '"' && !editorState.isOperatorPending && editorState.commandBuilder.expectedArgumentType == null
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleSelectRegister(vimStateMachine: VimStateMachine, chKey: Char) {
|
||||
@ -412,7 +417,9 @@ public class KeyHandler {
|
||||
val command = editorState.commandBuilder.buildCommand()
|
||||
val operatorArguments = OperatorArguments(
|
||||
editorState.mappingState.mappingMode == MappingMode.OP_PENDING,
|
||||
command.rawCount, editorState.mode, editorState.subMode
|
||||
command.rawCount,
|
||||
editorState.mode,
|
||||
editorState.subMode,
|
||||
)
|
||||
|
||||
// If we were in "operator pending" mode, reset back to normal mode.
|
||||
@ -665,6 +672,7 @@ public class KeyHandler {
|
||||
}
|
||||
|
||||
private val instance = KeyHandler()
|
||||
|
||||
@JvmStatic
|
||||
public fun getInstance(): KeyHandler = instance
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import javax.swing.KeyStroke
|
||||
public class UndoAction : VimActionHandler.SingleExecution(), ComplicatedKeysAction {
|
||||
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
|
||||
injector.parser.parseKeys("u"),
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_UNDO, 0))
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_UNDO, 0)),
|
||||
)
|
||||
|
||||
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
|
||||
|
@ -40,7 +40,7 @@ public class ChangeCaseLowerMotionAction : ChangeEditorActionHandler.ForEachCare
|
||||
context,
|
||||
CharacterHelper.CASE_LOWER,
|
||||
argument,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class ChangeCaseToggleMotionAction : ChangeEditorActionHandler.ForEachCar
|
||||
context,
|
||||
CharacterHelper.CASE_TOGGLE,
|
||||
argument,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class ChangeCaseUpperMotionAction : ChangeEditorActionHandler.ForEachCare
|
||||
context,
|
||||
CharacterHelper.CASE_UPPER,
|
||||
argument,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class ChangeLastSearchReplaceAction : ChangeEditorActionHandler.SingleExe
|
||||
for (caret in editor.carets()) {
|
||||
val line = caret.getBufferPosition().line
|
||||
if (!injector.searchGroup
|
||||
.processSubstituteCommand(editor, caret, LineRange(line, line), "s", "//~/", Script(listOf()))
|
||||
.processSubstituteCommand(editor, caret, LineRange(line, line), "s", "//~/", Script(listOf()))
|
||||
) {
|
||||
result = false
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class ChangeLineAction : ChangeEditorActionHandler.ForEachCaret() {
|
||||
caret,
|
||||
context,
|
||||
Argument(command),
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class ChangeMotionAction : ChangeEditorActionHandler.ForEachCaret(), Dupl
|
||||
caret,
|
||||
context,
|
||||
argument,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class ChangeVisualAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
range.toVimTextRange(false),
|
||||
range.type,
|
||||
context,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class ChangeVisualLinesAction : VisualOperatorActionHandler.ForEachCaret(
|
||||
val endsWithNewLine = if (lineEndForOffset.toLong() == editor.fileSize()) 0 else 1
|
||||
val lineRange = TextRange(
|
||||
editor.getLineStartForOffset(textRange.startOffset),
|
||||
lineEndForOffset + endsWithNewLine
|
||||
lineEndForOffset + endsWithNewLine,
|
||||
)
|
||||
return injector.changeGroup.changeRange(
|
||||
editor,
|
||||
@ -55,7 +55,7 @@ public class ChangeVisualLinesAction : VisualOperatorActionHandler.ForEachCaret(
|
||||
lineRange,
|
||||
SelectionType.LINE_WISE,
|
||||
context,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class ChangeVisualLinesEndAction : VisualOperatorActionHandler.ForEachCar
|
||||
val endsWithNewLine = if (lineEndForOffset.toLong() == editor.fileSize()) 0 else 1
|
||||
val lineRange = TextRange(
|
||||
editor.getLineStartForOffset(vimTextRange.startOffset),
|
||||
lineEndForOffset + endsWithNewLine
|
||||
lineEndForOffset + endsWithNewLine,
|
||||
)
|
||||
injector.changeGroup.changeRange(editor, caret, lineRange, SelectionType.LINE_WISE, context, operatorArguments)
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public abstract class DeleteCharacter(private val countModifier: (Int) -> Int) :
|
||||
caret,
|
||||
countModifier(operatorArguments.count1),
|
||||
false,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class DeleteVisualAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
range.toVimTextRange(false),
|
||||
selectionType,
|
||||
false,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class DeleteVisualLinesAction : VisualOperatorActionHandler.ForEachCaret(
|
||||
val endsWithNewLine = if (lineEndForOffset.toLong() == editor.fileSize()) 0 else 1
|
||||
val lineRange = TextRange(
|
||||
editor.getLineStartForOffset(textRange.startOffset),
|
||||
lineEndForOffset + endsWithNewLine
|
||||
lineEndForOffset + endsWithNewLine,
|
||||
)
|
||||
Triple(caret, lineRange, SelectionType.LINE_WISE)
|
||||
}
|
||||
|
@ -55,14 +55,14 @@ public class DeleteVisualLinesEndAction : VisualOperatorActionHandler.ForEachCar
|
||||
blockRange,
|
||||
SelectionType.BLOCK_WISE,
|
||||
false,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
} else {
|
||||
val lineEndForOffset = editor.getLineEndForOffset(vimTextRange.endOffset)
|
||||
val endsWithNewLine = if (lineEndForOffset.toLong() == editor.fileSize()) 0 else 1
|
||||
val lineRange = TextRange(
|
||||
editor.getLineStartForOffset(vimTextRange.startOffset),
|
||||
lineEndForOffset + endsWithNewLine
|
||||
lineEndForOffset + endsWithNewLine,
|
||||
)
|
||||
injector.changeGroup.deleteRange(editor, caret, lineRange, SelectionType.LINE_WISE, false, operatorArguments)
|
||||
}
|
||||
|
@ -33,7 +33,9 @@ public class InsertCharacterAboveCursorAction : ChangeEditorActionHandler.ForEac
|
||||
): Boolean {
|
||||
return if (editor.isOneLineMode()) {
|
||||
false
|
||||
} else insertCharacterAroundCursor(editor, caret, -1)
|
||||
} else {
|
||||
insertCharacterAroundCursor(editor, caret, -1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +51,9 @@ public class InsertCharacterBelowCursorAction : ChangeEditorActionHandler.ForEac
|
||||
): Boolean {
|
||||
return if (editor.isOneLineMode()) {
|
||||
false
|
||||
} else insertCharacterAroundCursor(editor, caret, 1)
|
||||
} else {
|
||||
insertCharacterAroundCursor(editor, caret, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ private fun insertDeleteInsertedText(
|
||||
TextRange(deleteTo.point, offset.point),
|
||||
SelectionType.CHARACTER_WISE,
|
||||
false,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
@ -85,8 +85,8 @@ private fun insertNewLineAbove(editor: VimEditor, context: ExecutionContext) {
|
||||
val hasGuards = moves.stream().anyMatch { (_, second): Pair<VimCaret?, Int?> ->
|
||||
editor.document.getOffsetGuard(
|
||||
Offset(
|
||||
second!!
|
||||
)
|
||||
second!!,
|
||||
),
|
||||
) != null
|
||||
}
|
||||
if (!hasGuards) {
|
||||
|
@ -36,7 +36,7 @@ public class InsertPreviousInsertExitAction : ChangeEditorActionHandler.SingleEx
|
||||
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_2, KeyEvent.CTRL_DOWN_MASK or KeyEvent.SHIFT_DOWN_MASK)),
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_2, KeyEvent.CTRL_DOWN_MASK)),
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_AT, KeyEvent.CTRL_DOWN_MASK))
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_AT, KeyEvent.CTRL_DOWN_MASK)),
|
||||
)
|
||||
|
||||
override val type: Command.Type = Command.Type.INSERT
|
||||
|
@ -77,7 +77,7 @@ private fun insertRegister(
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
key: Char,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
val register: Register? = injector.registerGroup.getRegister(key)
|
||||
if (register != null) {
|
||||
|
@ -83,7 +83,7 @@ public class ShiftLeftVisualAction : VisualOperatorActionHandler.ForEachCaret()
|
||||
range.toVimTextRange(false),
|
||||
cmd.count,
|
||||
-1,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class ShiftRightVisualAction : VisualOperatorActionHandler.ForEachCaret()
|
||||
range.toVimTextRange(false),
|
||||
cmd.count,
|
||||
1,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public sealed class PutTextBaseAction(
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
val count = operatorArguments.count1
|
||||
val sortedCarets = editor.sortedCarets()
|
||||
@ -60,7 +60,7 @@ public sealed class PutTextBaseAction(
|
||||
TextData(
|
||||
register.text ?: injector.parser.toPrintableString(register.keys),
|
||||
register.type,
|
||||
register.transferableData
|
||||
register.transferableData,
|
||||
)
|
||||
}
|
||||
return PutData(textData, null, count, insertTextBeforeCaret, indent, caretAfterInsertedText, -1)
|
||||
|
@ -62,7 +62,7 @@ public sealed class PutVisualTextBaseAction(
|
||||
PutData.TextData(
|
||||
register.text ?: injector.parser.toPrintableString(register.keys),
|
||||
register.type,
|
||||
register.transferableData
|
||||
register.transferableData,
|
||||
)
|
||||
}
|
||||
val visualSelection = selection?.let { PutData.VisualSelection(mapOf(caret to it), it.type) }
|
||||
|
@ -34,7 +34,7 @@ public class MotionArrowLeftAction : NonShiftedSpecialKeyHandler(), ComplicatedK
|
||||
caret: ImmutableVimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Motion {
|
||||
val allowWrap = injector.options(editor).hasValue(OptionConstants.whichwrap, "<")
|
||||
val allowEnd = operatorArguments.isOperatorPending // d<Left> deletes \n with wrap enabled
|
||||
|
@ -30,7 +30,7 @@ public class MotionArrowRightAction : NonShiftedSpecialKeyHandler(), Complicated
|
||||
|
||||
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
|
||||
injector.parser.parseKeys("<Right>"),
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, 0))
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, 0)),
|
||||
)
|
||||
|
||||
override fun motion(
|
||||
|
@ -32,7 +32,7 @@ public class MotionEndAction : NonShiftedSpecialKeyHandler() {
|
||||
caret: ImmutableVimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Motion {
|
||||
var allow = false
|
||||
if (editor.inInsertMode) {
|
||||
|
@ -27,7 +27,7 @@ public class MotionHomeAction : NonShiftedSpecialKeyHandler() {
|
||||
caret: ImmutableVimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Motion {
|
||||
return injector.motion.moveCaretToCurrentLineStart(editor, caret).toMotionOrError()
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class MotionLeftInsertModeAction : MotionActionHandler.ForEachCaret(), Co
|
||||
|
||||
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0)),
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, 0))
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, 0)),
|
||||
)
|
||||
|
||||
override fun getOffset(
|
||||
|
@ -47,7 +47,7 @@ public class MotionRightInsertAction : MotionActionHandler.ForEachCaret(), Compl
|
||||
|
||||
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0)),
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, 0))
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, 0)),
|
||||
)
|
||||
|
||||
override fun getOffset(
|
||||
|
@ -62,14 +62,14 @@ public sealed class TillCharacterMotion(
|
||||
editor,
|
||||
caret,
|
||||
direction.toInt() * operatorArguments.count1,
|
||||
argument.character
|
||||
argument.character,
|
||||
)
|
||||
} else {
|
||||
injector.motion.moveCaretToNextCharacterOnLine(
|
||||
editor,
|
||||
caret,
|
||||
direction.toInt() * operatorArguments.count1,
|
||||
argument.character
|
||||
argument.character,
|
||||
)
|
||||
}
|
||||
injector.motion.setLastFTCmd(tillCharacterMotionType, argument.character)
|
||||
|
@ -44,7 +44,6 @@ public abstract class MotionFirstScreenLineActionBase(private val operatorPendin
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Motion {
|
||||
|
||||
// Only apply scrolloff for NX motions. For op pending, use the actual first line and apply scrolloff after.
|
||||
// E.g. yH will yank from first visible line to current line, but it also moves the caret to the first visible line.
|
||||
// This is inside scrolloff, so Vim scrolls
|
||||
|
@ -33,7 +33,7 @@ public class MotionScrollFirstScreenLinePageStartAction : VimActionHandler.Singl
|
||||
var rawCount = cmd.rawCount
|
||||
if (rawCount == 0) {
|
||||
val nextVisualLine = editor.normalizeVisualLine(
|
||||
injector.engineEditorHelper.getVisualLineAtBottomOfScreen(editor) + 1
|
||||
injector.engineEditorHelper.getVisualLineAtBottomOfScreen(editor) + 1,
|
||||
)
|
||||
rawCount = editor.visualLineToBufferLine(nextVisualLine) + 1 // rawCount is 1 based
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class MotionScrollHalfWidthLeftAction : VimActionHandler.SingleExecution(
|
||||
// Vim's screen width is the full screen width, including columns used for gutters.
|
||||
return injector.scroll.scrollColumns(
|
||||
editor,
|
||||
cmd.count * (injector.engineEditorHelper.getApproximateScreenWidth(editor) / 2)
|
||||
cmd.count * (injector.engineEditorHelper.getApproximateScreenWidth(editor) / 2),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class MotionScrollPageDownAction : VimActionHandler.SingleExecution() {
|
||||
public class MotionScrollPageDownInsertModeAction : VimActionHandler.SingleExecution(), ComplicatedKeysAction {
|
||||
|
||||
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0))
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0)),
|
||||
)
|
||||
|
||||
override val type: Command.Type = Command.Type.OTHER_READONLY
|
||||
|
@ -37,7 +37,7 @@ public class MotionScrollPageUpAction : VimActionHandler.SingleExecution() {
|
||||
public class MotionScrollPageUpInsertModeAction : VimActionHandler.SingleExecution(), ComplicatedKeysAction {
|
||||
|
||||
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0))
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0)),
|
||||
)
|
||||
|
||||
override val type: Command.Type = Command.Type.OTHER_READONLY
|
||||
|
@ -26,7 +26,7 @@ public class MotionCamelLeftAction : MotionActionHandler.ForEachCaret() {
|
||||
caret: ImmutableVimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Motion {
|
||||
return injector.searchHelper.findPreviousCamelStart(editor.text(), caret.offset.point, operatorArguments.count1)
|
||||
?.toMotionOrError() ?: Motion.Error
|
||||
|
@ -43,7 +43,7 @@ public sealed class MotionSectionAction(private val charType: Char, public val d
|
||||
caret,
|
||||
charType,
|
||||
direction.toInt(),
|
||||
operatorArguments.count1
|
||||
operatorArguments.count1,
|
||||
).toMotionOrError()
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class MotionWordLeftInsertAction : MotionActionHandler.ForEachCaret(), Co
|
||||
|
||||
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.CTRL_DOWN_MASK)),
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, KeyEvent.CTRL_DOWN_MASK))
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, KeyEvent.CTRL_DOWN_MASK)),
|
||||
)
|
||||
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_SAVE_STROKE)
|
||||
|
@ -44,7 +44,7 @@ public class MotionWordRightInsertAction : MotionActionHandler.ForEachCaret(), C
|
||||
|
||||
override val keyStrokesSet: Set<List<KeyStroke>> = setOf(
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_DOWN_MASK)),
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, KeyEvent.CTRL_DOWN_MASK))
|
||||
listOf(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, KeyEvent.CTRL_DOWN_MASK)),
|
||||
)
|
||||
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_SAVE_STROKE)
|
||||
|
@ -32,7 +32,7 @@ public class MotionArrowDownAction : NonShiftedSpecialKeyHandler(), ComplicatedK
|
||||
caret: ImmutableVimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Motion {
|
||||
return injector.motion.getVerticalMotionOffset(editor, caret, operatorArguments.count1)
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class MotionArrowUpAction : NonShiftedSpecialKeyHandler(), ComplicatedKey
|
||||
caret: ImmutableVimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Motion {
|
||||
return injector.motion.getVerticalMotionOffset(editor, caret, -operatorArguments.count1)
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class MotionGotoLineLastAction : MotionActionHandler.ForEachCaret() {
|
||||
editor.lineCount() - 1
|
||||
} else {
|
||||
operatorArguments.count0 - 1
|
||||
}
|
||||
},
|
||||
)
|
||||
return injector.motion.moveCaretToLineWithStartOfLineOption(editor, line, caret).toMotion()
|
||||
}
|
||||
|
@ -82,6 +82,6 @@ private fun moveCaretGotoLineLastEnd(
|
||||
return injector.motion.moveCaretToLineEnd(
|
||||
editor,
|
||||
if (rawCount == 0) editor.normalizeLine(editor.lineCount() - 1) else line,
|
||||
pastEnd
|
||||
pastEnd,
|
||||
)
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class VisualSwapEndsAction : VimActionHandler.ForEachCaret() {
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean = swapVisualEnds(caret)
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,9 @@ public class VisualToggleBlockModeAction : VimActionHandler.SingleExecution() {
|
||||
): Boolean {
|
||||
return if (injector.options(editor).hasValue(OptionConstants.selectmode, OptionConstants.selectmode_cmd)) {
|
||||
injector.visualMotionGroup.enterSelectMode(editor, VimStateMachine.SubMode.VISUAL_BLOCK)
|
||||
} else injector.visualMotionGroup
|
||||
.toggleVisual(editor, cmd.count, cmd.rawCount, VimStateMachine.SubMode.VISUAL_BLOCK)
|
||||
} else {
|
||||
injector.visualMotionGroup
|
||||
.toggleVisual(editor, cmd.count, cmd.rawCount, VimStateMachine.SubMode.VISUAL_BLOCK)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,9 @@ public class VisualToggleCharacterModeAction : VimActionHandler.SingleExecution(
|
||||
): Boolean {
|
||||
return if (injector.options(editor).hasValue(OptionConstants.selectmode, OptionConstants.selectmode_cmd)) {
|
||||
injector.visualMotionGroup.enterSelectMode(editor, VimStateMachine.SubMode.VISUAL_CHARACTER)
|
||||
} else injector.visualMotionGroup
|
||||
.toggleVisual(editor, cmd.count, cmd.rawCount, VimStateMachine.SubMode.VISUAL_CHARACTER)
|
||||
} else {
|
||||
injector.visualMotionGroup
|
||||
.toggleVisual(editor, cmd.count, cmd.rawCount, VimStateMachine.SubMode.VISUAL_CHARACTER)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,6 +147,7 @@ public fun VimCaret.moveToMotion(motion: Motion): VimCaret {
|
||||
|
||||
public interface CaretRegisterStorage {
|
||||
public val caret: ImmutableVimCaret
|
||||
|
||||
/**
|
||||
* Stores text to caret's recordable (named/numbered/unnamed) register
|
||||
*/
|
||||
|
@ -48,7 +48,7 @@ public interface VimChangeGroup {
|
||||
caret: VimCaret,
|
||||
count: Int,
|
||||
isChange: Boolean,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean
|
||||
|
||||
public fun processSingleCommand(editor: VimEditor)
|
||||
@ -60,7 +60,7 @@ public interface VimChangeGroup {
|
||||
caret: VimCaret,
|
||||
count: Int,
|
||||
spaces: Boolean,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean
|
||||
|
||||
public fun processKey(editor: VimEditor, context: ExecutionContext, key: KeyStroke): Boolean
|
||||
@ -74,7 +74,7 @@ public interface VimChangeGroup {
|
||||
caret: VimCaret,
|
||||
range: TextRange,
|
||||
spaces: Boolean,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean
|
||||
|
||||
public fun joinViaIdeaByCount(editor: VimEditor, context: ExecutionContext, count: Int): Boolean
|
||||
@ -121,7 +121,7 @@ public interface VimChangeGroup {
|
||||
range: TextRange,
|
||||
type: SelectionType,
|
||||
context: ExecutionContext,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean
|
||||
|
||||
public fun changeCaseMotion(editor: VimEditor, caret: VimCaret, context: ExecutionContext?, type: Char, argument: Argument, operatorArguments: OperatorArguments): Boolean
|
||||
@ -140,7 +140,7 @@ public interface VimChangeGroup {
|
||||
context: ExecutionContext,
|
||||
lines: Int,
|
||||
dir: Int,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
)
|
||||
|
||||
public fun insertText(editor: VimEditor, caret: VimCaret, offset: Int, str: String): VimCaret
|
||||
@ -156,7 +156,7 @@ public interface VimChangeGroup {
|
||||
range: TextRange,
|
||||
count: Int,
|
||||
dir: Int,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
)
|
||||
|
||||
public fun changeNumberVisualMode(editor: VimEditor, caret: VimCaret, selectedRange: TextRange, count: Int, avalanche: Boolean): Boolean
|
||||
|
@ -105,7 +105,7 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
TextRange(caret.offset.point, endOffset.offset),
|
||||
SelectionType.CHARACTER_WISE,
|
||||
caret,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
val pos = caret.offset.point
|
||||
val norm = editor.normalizeOffset(caret.getBufferPosition().line, pos, isChange)
|
||||
@ -121,7 +121,7 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
val offset = editor.normalizeOffset(
|
||||
caret.getBufferPosition().line,
|
||||
caret.offset.point,
|
||||
isChange
|
||||
isChange,
|
||||
)
|
||||
caret.moveToOffset(offset)
|
||||
return res
|
||||
@ -163,7 +163,7 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
// Fix for https://youtrack.jetbrains.net/issue/VIM-35
|
||||
if (!range.normalize(editor.fileSize().toInt())) {
|
||||
updatedRange = if (range.startOffset == range.endOffset && range.startOffset == editor.fileSize()
|
||||
.toInt() && range.startOffset != 0
|
||||
.toInt() && range.startOffset != 0
|
||||
) {
|
||||
TextRange(range.startOffset - 1, range.endOffset)
|
||||
} else {
|
||||
@ -437,14 +437,20 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
if (cmd.flags.contains(CommandFlags.FLAG_NO_REPEAT_INSERT)) {
|
||||
val commandState = getInstance(editor)
|
||||
repeatInsert(
|
||||
editor, context, 1, false,
|
||||
OperatorArguments(false, 1, commandState.mode, commandState.subMode)
|
||||
editor,
|
||||
context,
|
||||
1,
|
||||
false,
|
||||
OperatorArguments(false, 1, commandState.mode, commandState.subMode),
|
||||
)
|
||||
} else {
|
||||
val commandState = getInstance(editor)
|
||||
repeatInsert(
|
||||
editor, context, cmd.count, false,
|
||||
OperatorArguments(false, cmd.count, commandState.mode, commandState.subMode)
|
||||
editor,
|
||||
context,
|
||||
cmd.count,
|
||||
false,
|
||||
OperatorArguments(false, cmd.count, commandState.mode, commandState.subMode),
|
||||
)
|
||||
}
|
||||
if (mode === VimStateMachine.Mode.REPLACE) {
|
||||
@ -651,7 +657,7 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
count: Int,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
val initialOffset = caret.offset.point
|
||||
val offset = injector.motion.moveCaretToRelativeLineEnd(editor, caret, count - 1, true)
|
||||
@ -697,7 +703,9 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
val total = editor.lineCount()
|
||||
return if (lline + myCount > total) {
|
||||
false
|
||||
} else deleteJoinNLines(editor, caret, lline, myCount, spaces, operatorArguments)
|
||||
} else {
|
||||
deleteJoinNLines(editor, caret, lline, myCount, spaces, operatorArguments)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -755,7 +763,7 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
count: Int,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
val start = injector.motion.moveCaretToCurrentLineStart(editor, caret)
|
||||
val offset =
|
||||
@ -771,8 +779,9 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
caret.moveToOffset(
|
||||
injector.motion.moveCaretToRelativeLineStartSkipLeading(
|
||||
editor,
|
||||
caret, -1
|
||||
)
|
||||
caret,
|
||||
-1,
|
||||
),
|
||||
)
|
||||
}
|
||||
return res
|
||||
@ -831,7 +840,7 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
val (first, second) = range.getNativeStartAndEnd()
|
||||
caret.setSelection(
|
||||
first.offset,
|
||||
second.offset
|
||||
second.offset,
|
||||
)
|
||||
}
|
||||
val joinLinesAction = injector.nativeActionManager.joinLines
|
||||
@ -899,7 +908,6 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
operatorArguments: OperatorArguments,
|
||||
saveToRegister: Boolean,
|
||||
): Boolean {
|
||||
|
||||
val intendedColumn = caret.vimLastColumn
|
||||
|
||||
val removeLastNewLine = removeLastNewLine(editor, range, type)
|
||||
@ -919,11 +927,14 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
val updated = processedCaret.setVimLastColumnAndGetCaret(intendedColumn)
|
||||
pos = injector.motion
|
||||
.moveCaretToLineWithStartOfLineOption(
|
||||
editor, editor.offsetToBufferPosition(pos).line,
|
||||
caret
|
||||
editor,
|
||||
editor.offsetToBufferPosition(pos).line,
|
||||
caret,
|
||||
)
|
||||
updated
|
||||
} else caret
|
||||
} else {
|
||||
caret
|
||||
}
|
||||
processedCaret = processedCaret.moveToOffset(pos)
|
||||
|
||||
// Ensure the intended column cache is invalidated - it will only happen automatically if the caret actually moves
|
||||
@ -957,7 +968,7 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
count: Int,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
val res = deleteEndOfLine(editor, caret, count, operatorArguments)
|
||||
if (res) {
|
||||
@ -1027,7 +1038,8 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
val start = injector.motion.moveCaretToCurrentLineEnd(editor, caret)
|
||||
val trailingWhitespaceStart = injector.motion.moveCaretToRelativeLineEndSkipTrailing(
|
||||
editor,
|
||||
caret, 0
|
||||
caret,
|
||||
0,
|
||||
)
|
||||
val hasTrailingWhitespace = start != trailingWhitespaceStart + 1
|
||||
caret.moveToOffset(start)
|
||||
@ -1040,7 +1052,7 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
if (spaces && !hasTrailingWhitespace) {
|
||||
insertText(editor, caret, " ")
|
||||
caret.moveToMotion(
|
||||
injector.motion.getHorizontalMotion(editor, caret, -1, true)
|
||||
injector.motion.getHorizontalMotion(editor, caret, -1, true),
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -1090,8 +1102,8 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
val newCaret = caret.moveToOffset(
|
||||
injector.motion.moveCaretToCurrentLineStart(
|
||||
editor,
|
||||
caret
|
||||
)
|
||||
caret,
|
||||
),
|
||||
)
|
||||
firstLiner = true
|
||||
newCaret
|
||||
@ -1104,7 +1116,9 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
}
|
||||
editor.vimChangeActionSwitchMode = VimStateMachine.Mode.INSERT
|
||||
newCaret = insertText(
|
||||
editor, newCaret, "\n${editor.createIndentBySize(col)}"
|
||||
editor,
|
||||
newCaret,
|
||||
"\n${editor.createIndentBySize(col)}",
|
||||
)
|
||||
if (firstLiner) {
|
||||
// TODO: getVerticalMotionOffset returns a visual line, not the expected logical line
|
||||
@ -1186,11 +1200,15 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
context,
|
||||
argument,
|
||||
true,
|
||||
operatorArguments.withCount0(count0)
|
||||
operatorArguments.withCount0(count0),
|
||||
) ?: return false
|
||||
return changeRange(
|
||||
editor, caret, first, second, context,
|
||||
operatorArguments
|
||||
editor,
|
||||
caret,
|
||||
first,
|
||||
second,
|
||||
context,
|
||||
operatorArguments,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,8 @@ public abstract class VimDigraphGroupBase() : VimDigraphGroup {
|
||||
ch.code,
|
||||
ch.code,
|
||||
ch.code,
|
||||
digraphText
|
||||
)
|
||||
digraphText,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
injector.messages.showStatusBarMessage(
|
||||
@ -54,8 +54,8 @@ public abstract class VimDigraphGroupBase() : VimDigraphGroup {
|
||||
ch.code,
|
||||
ch.code,
|
||||
ch.code,
|
||||
digraphText
|
||||
)
|
||||
digraphText,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -1679,7 +1679,7 @@ public abstract class VimDigraphGroupBase() : VimDigraphGroup {
|
||||
'f', 'i', '\ufb01', // LATIN SMALL LIGATURE FI
|
||||
'f', 'l', '\ufb02', // LATIN SMALL LIGATURE FL
|
||||
'f', 't', '\ufb05', // LATIN SMALL LIGATURE FT
|
||||
's', 't', '\ufb06'
|
||||
's', 't', '\ufb06',
|
||||
)
|
||||
protected val digraphs: HashMap<String, Char> = HashMap<String, Char>(defaultDigraphs.size)
|
||||
protected val keys: TreeMap<Char, String> = TreeMap<Char, String>()
|
||||
|
@ -158,6 +158,7 @@ public interface VimEditor {
|
||||
private fun List<VimCaret>.sortedByOffset(): List<VimCaret> {
|
||||
return this.sortedWith(compareBy { it.offset.point }).reversed()
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should perform caret merging after the operations. This is similar to IJ runForEachCaret
|
||||
* TODO review
|
||||
|
@ -26,24 +26,31 @@ import com.maddyhome.idea.vim.yank.VimYankGroup
|
||||
public interface VimInjector {
|
||||
// [FINISHED] Fully moved to vim-engine. Should we remove it from injector?
|
||||
public val parser: VimStringParser
|
||||
|
||||
// [FINISHED] Can't be fully moved to vim-engine
|
||||
public val messages: VimMessages
|
||||
|
||||
// [FINISHED] Fully moved to vim-engine. Only state left in the IJ
|
||||
// Let's keep the state saver as is until we'll figure out how to implement this in fleet.
|
||||
public val registerGroup: VimRegisterGroup
|
||||
public val registerGroupIfCreated: VimRegisterGroup?
|
||||
|
||||
// [FINISHED] Can't be fully moved to vim-engine.
|
||||
// Lots of interaction with EX panel. Let's refactor it when figure out how it works in fleet.
|
||||
public val processGroup: VimProcessGroup
|
||||
|
||||
// [FINISHED] Can't be fully moved to vim-engine.
|
||||
// A lot of interaction with IJ.
|
||||
public val application: VimApplication
|
||||
|
||||
// [FINISHED] Can't be fully moved to vim-engine.
|
||||
// Getting contextes. Need to clarify how it works in fleet before refactoring.
|
||||
public val executionContextManager: ExecutionContextManager
|
||||
|
||||
// [FINISHED] Fully moved to vim-engine except one method that iterates with IJ.
|
||||
// Need to check how it would work in fleet before moving this method.
|
||||
public val digraphGroup: VimDigraphGroup
|
||||
|
||||
// [FINISHED] Can't be fully moved to vim-engine.
|
||||
public val enabler: VimEnabler
|
||||
|
||||
@ -57,8 +64,10 @@ public interface VimInjector {
|
||||
|
||||
// [FINISHED] Can't be fully moved to vim-engine.
|
||||
public val nativeActionManager: NativeActionManager
|
||||
|
||||
// [FINISHED] Can't be fully moved to vim-engine.
|
||||
public val keyGroup: VimKeyGroup
|
||||
|
||||
// [FINISHED] Only state left in the IJ && some IJ specifics
|
||||
public val markService: VimMarkService
|
||||
|
||||
@ -66,6 +75,7 @@ public interface VimInjector {
|
||||
|
||||
// [FINISHED] Only IJ staff left
|
||||
public val visualMotionGroup: VimVisualMotionGroup
|
||||
|
||||
// [FINISHED] Class moved to vim-engine, but it's attached to Editor using IJ things
|
||||
public fun commandStateFor(editor: VimEditor): VimStateMachine
|
||||
// [FINISHED] Class moved to vim-engine, but it's attached to Editor using IJ things
|
||||
@ -74,67 +84,95 @@ public interface VimInjector {
|
||||
* Please see: https://jb.gg/zo8n0r
|
||||
*/
|
||||
public fun commandStateFor(editor: Any): VimStateMachine
|
||||
|
||||
// !! in progress
|
||||
public val engineEditorHelper: EngineEditorHelper
|
||||
|
||||
// [FINISHED] Only IJ staff
|
||||
public val editorGroup: VimEditorGroup
|
||||
|
||||
// [FINISHED] Fully moved to vim-engine. Should we remove it from injector?
|
||||
public val commandGroup: VimCommandGroup
|
||||
|
||||
// !! in progress
|
||||
public val changeGroup: VimChangeGroup
|
||||
|
||||
// Can't be fully moved to vim-engine.
|
||||
public val actionExecutor: VimActionExecutor
|
||||
|
||||
// Can't be fully moved to vim-engine.
|
||||
public val exEntryPanel: ExEntryPanel
|
||||
|
||||
// Can't be fully moved to vim-engine.
|
||||
public val exOutputPanel: VimExOutputPanelService
|
||||
|
||||
// Can't be fully moved to vim-engine.
|
||||
public val clipboardManager: VimClipboardManager
|
||||
|
||||
// Only state left in the IJ
|
||||
public val historyGroup: VimHistory
|
||||
|
||||
// !! in progress
|
||||
public val extensionRegistrator: VimExtensionRegistrator
|
||||
|
||||
// Can't be fully moved to vim-engine.
|
||||
public val tabService: TabService
|
||||
|
||||
// !! in progress
|
||||
public val regexpService: VimRegexpService
|
||||
|
||||
// !! in progress
|
||||
public val searchHelper: VimSearchHelper
|
||||
|
||||
// !! in progress
|
||||
public val motion: VimMotionGroup
|
||||
public val scroll: VimScrollGroup
|
||||
|
||||
// Can't be fully moved to vim-engine.
|
||||
public val lookupManager: VimLookupManager
|
||||
|
||||
// Can't be fully moved to vim-engine.
|
||||
public val templateManager: VimTemplateManager
|
||||
|
||||
// !! in progress
|
||||
public val searchGroup: VimSearchGroup
|
||||
|
||||
// Can't be fully moved to vim-engine.
|
||||
public val statisticsService: VimStatistics
|
||||
|
||||
// !! in progress
|
||||
public val put: VimPut
|
||||
|
||||
// Can't be fully moved to vim-engine.
|
||||
public val window: VimWindowGroup
|
||||
|
||||
// !! in progress
|
||||
public val yank: VimYankGroup
|
||||
|
||||
// !! in progress
|
||||
public val file: VimFile
|
||||
|
||||
// !! in progress
|
||||
public val macro: VimMacro
|
||||
|
||||
// !! in progress
|
||||
public val undo: VimUndoRedo
|
||||
|
||||
// !! in progress
|
||||
public val commandLineHelper: VimCommandLineHelper
|
||||
|
||||
// Can't be fully moved to vim-engine.
|
||||
public val vimscriptExecutor: VimscriptExecutor
|
||||
|
||||
// Can't be fully moved to vim-engine.
|
||||
public val vimscriptParser: VimscriptParser
|
||||
|
||||
// !! in progress
|
||||
public val variableService: VariableService
|
||||
|
||||
// !! in progress
|
||||
public val functionService: VimscriptFunctionService
|
||||
|
||||
// Can't be fully moved to vim-engine.
|
||||
public val vimrcFileState: VimrcFileState
|
||||
|
||||
|
@ -32,6 +32,7 @@ public abstract class VimInjectorBase : VimInjector {
|
||||
|
||||
override val parser: VimStringParser = object : VimStringParserBase() {}
|
||||
override val optionGroup: VimOptionGroup by lazy { object : VimOptionGroupBase() {} }
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated("Use optionGroup")
|
||||
final override val optionService: OptionService = OptionServiceImpl()
|
||||
|
@ -96,12 +96,15 @@ public abstract class VimKeyGroupBase : VimKeyGroup {
|
||||
}
|
||||
|
||||
val actionExceptions = listOf(
|
||||
"VimInsertDeletePreviousWordAction", "VimInsertAfterCursorAction", "VimInsertBeforeCursorAction",
|
||||
"VimFilterVisualLinesAction", "VimAutoIndentMotionAction"
|
||||
"VimInsertDeletePreviousWordAction",
|
||||
"VimInsertAfterCursorAction",
|
||||
"VimInsertBeforeCursorAction",
|
||||
"VimFilterVisualLinesAction",
|
||||
"VimAutoIndentMotionAction",
|
||||
)
|
||||
if (i == shortOne && action.id !in actionExceptions && entry.value !in actionExceptions) {
|
||||
throw RuntimeException(
|
||||
"Prefix found! $keys in command ${action.id} is the same as ${prefix.joinToString(", ") { it.toString() }} in ${entry.value}"
|
||||
"Prefix found! $keys in command ${action.id} is the same as ${prefix.joinToString(", ") { it.toString() }} in ${entry.value}",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public abstract class VimMarkServiceBase : VimMarkService {
|
||||
public companion object {
|
||||
private val logger = vimLogger<VimMarkServiceBase>()
|
||||
}
|
||||
|
||||
@JvmField
|
||||
protected val globalMarks: java.util.HashMap<Char, Mark> = HashMap()
|
||||
|
||||
|
@ -41,8 +41,9 @@ public abstract class VimMotionGroupBase : VimMotionGroup {
|
||||
|
||||
if (intendedColumn == LAST_COLUMN) {
|
||||
val normalisedColumn = editor.normalizeVisualColumn(
|
||||
line, intendedColumn,
|
||||
editor.mode.isEndAllowedIgnoringOnemore
|
||||
line,
|
||||
intendedColumn,
|
||||
editor.mode.isEndAllowedIgnoringOnemore,
|
||||
)
|
||||
val newPos = VimVisualPosition(line, normalisedColumn, false)
|
||||
return editor.visualPositionToOffset(newPos).point.toAdjustedMotionOrError(intendedColumn)
|
||||
@ -75,7 +76,7 @@ public abstract class VimMotionGroupBase : VimMotionGroup {
|
||||
return editor.normalizeOffset(
|
||||
line,
|
||||
editor.getLineEndOffset(line, allowPastEnd),
|
||||
allowPastEnd
|
||||
allowPastEnd,
|
||||
)
|
||||
}
|
||||
|
||||
@ -203,14 +204,16 @@ public abstract class VimMotionGroupBase : VimMotionGroup {
|
||||
): Int {
|
||||
val line = editor.normalizeVisualLine(caret.getVisualPosition().line + cntForward)
|
||||
|
||||
return if (line < 0) 0 else {
|
||||
return if (line < 0) {
|
||||
0
|
||||
} else {
|
||||
moveCaretToLineEnd(editor, editor.visualLineToBufferLine(line), allowPastEnd)
|
||||
}
|
||||
}
|
||||
|
||||
override fun moveCaretToRelativeLineEndSkipTrailing(editor: VimEditor, caret: ImmutableVimCaret, linesOffset: Int): Int {
|
||||
val line = editor.visualLineToBufferLine(
|
||||
editor.normalizeVisualLine(caret.getVisualPosition().line + linesOffset)
|
||||
editor.normalizeVisualLine(caret.getVisualPosition().line + linesOffset),
|
||||
)
|
||||
val start = editor.getLineStartOffset(line)
|
||||
val end = editor.getLineEndOffset(line, true)
|
||||
@ -311,7 +314,7 @@ public abstract class VimMotionGroupBase : VimMotionGroup {
|
||||
if (cmd.isLinewiseMotion()) end--
|
||||
} else {
|
||||
throw RuntimeException(
|
||||
"Commands doesn't take " + cmdAction.javaClass.simpleName + " as an operator"
|
||||
"Commands doesn't take " + cmdAction.javaClass.simpleName + " as an operator",
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,8 @@ public inline fun <TDataType : VimDataType> VimOptionGroup.modifyOptionValue(
|
||||
scope: OptionScope,
|
||||
transform: (TDataType) -> TDataType?,
|
||||
) {
|
||||
@Suppress("UNCHECKED_CAST") val currentValue = getOptionValue(option, scope) as TDataType
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val currentValue = getOptionValue(option, scope) as TDataType
|
||||
transform(currentValue)?.let {
|
||||
setOptionValue(option, scope, it)
|
||||
}
|
||||
|
@ -71,14 +71,15 @@ public abstract class VimOptionGroupBase : VimOptionGroup {
|
||||
|
||||
// Options with longer defaults or additional validation, sorted by name
|
||||
object : StringOption(
|
||||
OptionConstants.guicursor, "gcr",
|
||||
OptionConstants.guicursor,
|
||||
"gcr",
|
||||
"n-v-c:block-Cursor/lCursor," +
|
||||
"ve:ver35-Cursor," +
|
||||
"o:hor50-Cursor," +
|
||||
"i-ci:ver25-Cursor/lCursor," +
|
||||
"r-cr:hor20-Cursor/lCursor," +
|
||||
"sm:block-Cursor-blinkwait175-blinkoff150-blinkon175",
|
||||
isList = true
|
||||
isList = true,
|
||||
) {
|
||||
override fun checkIfValueValid(value: VimDataType, token: String) {
|
||||
super.checkIfValueValid(value, token)
|
||||
@ -115,8 +116,8 @@ public abstract class VimOptionGroupBase : VimOptionGroup {
|
||||
OptionConstants.keymodel_stopselect,
|
||||
OptionConstants.keymodel_stopvisual,
|
||||
OptionConstants.keymodel_continueselect,
|
||||
OptionConstants.keymodel_continuevisual
|
||||
)
|
||||
OptionConstants.keymodel_continuevisual,
|
||||
),
|
||||
),
|
||||
object : StringOption(OptionConstants.matchpairs, "mps", "(:),{:},[:]", isList = true) {
|
||||
override fun checkIfValueValid(value: VimDataType, token: String) {
|
||||
@ -137,13 +138,16 @@ public abstract class VimOptionGroupBase : VimOptionGroup {
|
||||
}
|
||||
},
|
||||
StringOption(
|
||||
OptionConstants.selectmode, "slm", "", isList = true,
|
||||
OptionConstants.selectmode,
|
||||
"slm",
|
||||
"",
|
||||
isList = true,
|
||||
setOf(
|
||||
OptionConstants.selectmode_mouse,
|
||||
OptionConstants.selectmode_key,
|
||||
OptionConstants.selectmode_cmd,
|
||||
OptionConstants.selectmode_ideaselection
|
||||
)
|
||||
OptionConstants.selectmode_ideaselection,
|
||||
),
|
||||
),
|
||||
object : StringOption(OptionConstants.shellcmdflag, "shcf", "") {
|
||||
override val defaultValue: VimString
|
||||
@ -155,7 +159,7 @@ public abstract class VimOptionGroupBase : VimOptionGroup {
|
||||
injector.systemInfoService.isWindows && shell.contains("powershell") -> "-Command"
|
||||
injector.systemInfoService.isWindows && !shell.contains("sh") -> "/c"
|
||||
else -> "-c"
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
},
|
||||
@ -169,7 +173,7 @@ public abstract class VimOptionGroupBase : VimOptionGroup {
|
||||
injector.systemInfoService.isWindows && shell == "cmd.exe" -> "("
|
||||
injector.systemInfoService.isWindows && shell.contains("sh") -> "\""
|
||||
else -> ""
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
},
|
||||
|
@ -20,6 +20,7 @@ public interface VimProcessGroup {
|
||||
public fun startExCommand(editor: VimEditor, context: ExecutionContext?, cmd: Command)
|
||||
public fun processExEntry(editor: VimEditor, context: ExecutionContext): Boolean
|
||||
public fun cancelExEntry(editor: VimEditor, resetCaret: Boolean)
|
||||
|
||||
@kotlin.jvm.Throws(java.lang.Exception::class)
|
||||
public fun executeCommand(editor: VimEditor, command: String, input: CharSequence?, currentDirectoryPath: String?): String?
|
||||
}
|
||||
|
@ -40,12 +40,14 @@ public interface VimSearchGroup {
|
||||
exarg: String,
|
||||
parent: VimLContext,
|
||||
): Boolean
|
||||
|
||||
// TODO rewrite this
|
||||
public fun search_regcomp(pat: CharPointer?, which_pat: Int, patSave: Int): Pair<Boolean, Triple<Any, String, Any>>
|
||||
public fun findDecimalNumber(line: String): Int?
|
||||
public fun clearSearchHighlight()
|
||||
|
||||
public fun getLastSearchDirection(): Direction
|
||||
|
||||
// Matching the values defined in Vim. Do not change these values, they are used as indexes
|
||||
public companion object {
|
||||
public val RE_SEARCH: Int = 0 // Save/use search pattern
|
||||
|
@ -247,7 +247,7 @@ public abstract class VimSearchHelperBase : VimSearchHelper {
|
||||
var counter = 0
|
||||
var offset = startIndex
|
||||
while (counter < count) {
|
||||
val searchFrom = if (counter == 0) offset else offset + direction.toInt()
|
||||
val searchFrom = if (counter == 0) offset else offset + direction.toInt()
|
||||
offset = findCamelStart(chars, searchFrom, direction) ?: return null
|
||||
++counter
|
||||
}
|
||||
@ -262,7 +262,7 @@ public abstract class VimSearchHelperBase : VimSearchHelper {
|
||||
var counter = 0
|
||||
var offset = startIndex
|
||||
while (counter < count) {
|
||||
val searchFrom = if (counter == 0) offset else offset + direction.toInt()
|
||||
val searchFrom = if (counter == 0) offset else offset + direction.toInt()
|
||||
offset = findCamelEnd(chars, searchFrom, direction) ?: return null
|
||||
++counter
|
||||
}
|
||||
@ -279,11 +279,12 @@ public abstract class VimSearchHelperBase : VimSearchHelper {
|
||||
if (pos < 0 || pos >= size) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
while (pos in 0 until size) {
|
||||
if (chars[pos].isUpperCase()) {
|
||||
if ((pos == 0 || !chars[pos - 1].isUpperCase()) ||
|
||||
(pos == size - 1 || chars[pos + 1].isLowerCase())) {
|
||||
(pos == size - 1 || chars[pos + 1].isLowerCase())
|
||||
) {
|
||||
return pos
|
||||
}
|
||||
} else if (chars[pos].isLowerCase()) {
|
||||
@ -313,8 +314,9 @@ public abstract class VimSearchHelperBase : VimSearchHelper {
|
||||
|
||||
while (pos in 0 until size) {
|
||||
if (chars[pos].isUpperCase()) {
|
||||
if (pos == size - 1 || !chars[pos + 1].isLetter() ||
|
||||
(chars[pos + 1].isUpperCase() && pos < size - 2 && chars[pos + 2].isLowerCase())) {
|
||||
if (pos == size - 1 || !chars[pos + 1].isLetter() ||
|
||||
(chars[pos + 1].isUpperCase() && pos < size - 2 && chars[pos + 2].isLowerCase())
|
||||
) {
|
||||
return pos
|
||||
}
|
||||
} else if (chars[pos].isLowerCase()) {
|
||||
@ -330,16 +332,16 @@ public abstract class VimSearchHelperBase : VimSearchHelper {
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
override fun findBlockQuoteInLineRange(editor: VimEditor, caret: ImmutableVimCaret, quote: Char, isOuter: Boolean): TextRange? {
|
||||
var leftQuote: Int
|
||||
var rightQuote: Int
|
||||
|
||||
|
||||
val caretOffset = caret.offset.point
|
||||
val quoteAfterCaret : Int = editor.text().indexOfNext(quote, caretOffset, true) ?: return null
|
||||
val quoteBeforeCaret : Int? = editor.text().indexOfPrevious(quote, caretOffset, true)
|
||||
val quotesBeforeCaret : Int = editor.text().occurrencesBeforeOffset(quote, caretOffset, true)
|
||||
|
||||
val quoteAfterCaret: Int = editor.text().indexOfNext(quote, caretOffset, true) ?: return null
|
||||
val quoteBeforeCaret: Int? = editor.text().indexOfPrevious(quote, caretOffset, true)
|
||||
val quotesBeforeCaret: Int = editor.text().occurrencesBeforeOffset(quote, caretOffset, true)
|
||||
|
||||
if (((caretOffset == quoteAfterCaret) && quotesBeforeCaret % 2 == 0) || quoteBeforeCaret == null) {
|
||||
leftQuote = quoteAfterCaret
|
||||
rightQuote = editor.text().indexOfNext(quote, leftQuote + 1, true) ?: return null
|
||||
@ -372,8 +374,8 @@ public abstract class VimSearchHelperBase : VimSearchHelper {
|
||||
* @param startIndex index to start the search from, included in search
|
||||
* @param currentLineOnly true if search should stop after reaching '\n'
|
||||
* @param searchEscaped true if escaped chars should appear in search
|
||||
*
|
||||
* @return the closest to [startIndex] position of [char], or null if no [char] was found
|
||||
*
|
||||
* @return the closest to [startIndex] position of [char], or null if no [char] was found
|
||||
*/
|
||||
private fun CharSequence.indexOfNext(char: Char, startIndex: Int, currentLineOnly: Boolean, searchEscaped: Boolean = false): Int? {
|
||||
return findCharacterPosition(this, char, startIndex, Direction.FORWARDS, currentLineOnly, searchEscaped)
|
||||
@ -385,7 +387,7 @@ public abstract class VimSearchHelperBase : VimSearchHelper {
|
||||
* @param currentLineOnly true if search should stop after reaching '\n'
|
||||
* @param searchEscaped true if escaped chars should appear in search
|
||||
*
|
||||
* @return the closest to [endIndex] position of [char], or null if no [char] was found
|
||||
* @return the closest to [endIndex] position of [char], or null if no [char] was found
|
||||
*/
|
||||
private fun CharSequence.indexOfPrevious(char: Char, endIndex: Int, currentLineOnly: Boolean, searchEscaped: Boolean = false): Int? {
|
||||
if (endIndex == 0 || (currentLineOnly && this[endIndex - 1] == '\n')) return null
|
||||
@ -400,8 +402,8 @@ public abstract class VimSearchHelperBase : VimSearchHelper {
|
||||
* @param currentLineOnly true if search should break after reaching '\n'
|
||||
* @param searchEscaped true if escaped chars should be returned
|
||||
* @param direction direction to search (forward/backward)
|
||||
*
|
||||
* @return index of the closest char found (null if nothing was found)
|
||||
*
|
||||
* @return index of the closest char found (null if nothing was found)
|
||||
*/
|
||||
private fun findCharacterPosition(charSequence: CharSequence, char: Char, startIndex: Int, direction: Direction, currentLineOnly: Boolean, searchEscaped: Boolean): Int? {
|
||||
var pos = startIndex
|
||||
|
@ -17,6 +17,7 @@ public interface VimStringParser {
|
||||
* Fake key for `<Plug>` mappings
|
||||
*/
|
||||
public val plugKeyStroke: KeyStroke
|
||||
|
||||
/**
|
||||
* Fake key for `<Action>` mappings
|
||||
*/
|
||||
@ -64,4 +65,4 @@ public interface VimStringParser {
|
||||
|
||||
public fun key(string: String): KeyStroke {
|
||||
return injector.parser.parseKeys(string).single()
|
||||
}
|
||||
}
|
||||
|
@ -442,7 +442,9 @@ public abstract class VimStringParserBase : VimStringParser {
|
||||
private fun octalDigitToNumber(c: Char): Int? {
|
||||
return if (c in '0'..'7') {
|
||||
c.code - '0'.code
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun hexDigitToNumber(c: Char): Int? {
|
||||
|
@ -44,12 +44,13 @@ public class Argument private constructor(
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
) = Motion.NoMotion
|
||||
|
||||
override val motionType: MotionType = MotionType.EXCLUSIVE
|
||||
},
|
||||
Command.Type.MOTION, EnumSet.noneOf(CommandFlags::class.java)
|
||||
Command.Type.MOTION,
|
||||
EnumSet.noneOf(CommandFlags::class.java),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public data class Command(
|
||||
rawCount,
|
||||
NonExecutableActionHandler,
|
||||
Type.SELECT_REGISTER,
|
||||
EnumSet.of(CommandFlags.FLAG_EXPECT_MORE)
|
||||
EnumSet.of(CommandFlags.FLAG_EXPECT_MORE),
|
||||
) {
|
||||
this.register = register
|
||||
}
|
||||
@ -94,7 +94,9 @@ public data class Command(
|
||||
/**
|
||||
* Represent commands that don't require an outer read or write action for synchronization.
|
||||
*/
|
||||
OTHER_SELF_SYNCHRONIZED;
|
||||
OTHER_SELF_SYNCHRONIZED,
|
||||
|
||||
;
|
||||
|
||||
public val isRead: Boolean
|
||||
get() = when (this) {
|
||||
@ -119,7 +121,7 @@ private object NonExecutableActionHandler : EditorActionHandlerBase(false) {
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
error("This action should not be executed")
|
||||
}
|
||||
|
@ -15,12 +15,12 @@ package com.maddyhome.idea.vim.command
|
||||
public enum class MotionType {
|
||||
INCLUSIVE,
|
||||
EXCLUSIVE,
|
||||
LINE_WISE
|
||||
LINE_WISE,
|
||||
}
|
||||
|
||||
public enum class TextObjectVisualType {
|
||||
CHARACTER_WISE,
|
||||
LINE_WISE
|
||||
LINE_WISE,
|
||||
}
|
||||
|
||||
public enum class CommandFlags {
|
||||
|
@ -43,7 +43,9 @@ public enum class MappingMode {
|
||||
/**
|
||||
* Indicates this key mapping applies to Command Line mode
|
||||
*/
|
||||
CMD_LINE;
|
||||
CMD_LINE,
|
||||
|
||||
;
|
||||
|
||||
public companion object {
|
||||
@JvmField
|
||||
|
@ -116,7 +116,6 @@ public object MappingProcessor {
|
||||
}
|
||||
log.trace("processing unhandled keys...")
|
||||
for ((index, keyStroke) in unhandledKeys.withIndex()) {
|
||||
|
||||
// Related issue: VIM-2315
|
||||
// If we have two mappings: for `abc` and for `ab`, after typing `ab` we should wait a bit and execute
|
||||
// `ab` mapping
|
||||
@ -125,12 +124,15 @@ public object MappingProcessor {
|
||||
val lastKeyInSequence = index == unhandledKeys.lastIndex
|
||||
|
||||
KeyHandler.getInstance().handleKey(
|
||||
editor, keyStroke, injector.executionContextManager.onEditor(editor),
|
||||
editor,
|
||||
keyStroke,
|
||||
injector.executionContextManager.onEditor(editor),
|
||||
allowKeyMappings = true,
|
||||
mappingCompleted = lastKeyInSequence
|
||||
mappingCompleted = lastKeyInSequence,
|
||||
)
|
||||
}
|
||||
}, editor
|
||||
},
|
||||
editor,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -185,7 +187,7 @@ public object MappingProcessor {
|
||||
"""
|
||||
Caught exception during ${mappingInfo.getPresentableString()}
|
||||
${e.message}
|
||||
""".trimIndent()
|
||||
""".trimIndent(),
|
||||
)
|
||||
} catch (e: NotImplementedError) {
|
||||
injector.messages.showStatusBarMessage(editor, e.message)
|
||||
@ -194,7 +196,7 @@ public object MappingProcessor {
|
||||
"""
|
||||
Caught exception during ${mappingInfo.getPresentableString()}
|
||||
${e.message}
|
||||
""".trimIndent()
|
||||
""".trimIndent(),
|
||||
)
|
||||
} finally {
|
||||
mappingState.stopMapExecution()
|
||||
@ -236,9 +238,11 @@ public object MappingProcessor {
|
||||
if (isPluginMapping(unhandledKeyStrokes)) {
|
||||
log.trace("This is a plugin mapping, process it")
|
||||
KeyHandler.getInstance().handleKey(
|
||||
editor, unhandledKeyStrokes[unhandledKeyStrokes.size - 1], context,
|
||||
editor,
|
||||
unhandledKeyStrokes[unhandledKeyStrokes.size - 1],
|
||||
context,
|
||||
allowKeyMappings = true,
|
||||
mappingCompleted = false
|
||||
mappingCompleted = false,
|
||||
)
|
||||
} else {
|
||||
log.trace("Process abandoned keys.")
|
||||
|
@ -16,7 +16,8 @@ public enum class SelectionType(public val value: Int) {
|
||||
// Integer values for registers serialization in RegisterGroup.readData()
|
||||
LINE_WISE(1 shl 1),
|
||||
CHARACTER_WISE(1 shl 2),
|
||||
BLOCK_WISE(1 shl 3);
|
||||
BLOCK_WISE(1 shl 3),
|
||||
;
|
||||
|
||||
public fun toSubMode(): SubMode = when (this) {
|
||||
LINE_WISE -> SubMode.VISUAL_LINE
|
||||
|
@ -48,7 +48,7 @@ public sealed class CommandAlias(
|
||||
Arguments -> arrayOf(cleanedInput)
|
||||
QuotedArguments -> arrayOf("'$cleanedInput'")
|
||||
else -> emptyArray()
|
||||
}.joinToString(", ")
|
||||
}.joinToString(", "),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -11,5 +11,5 @@ package com.maddyhome.idea.vim.common
|
||||
public enum class CurrentCommandState {
|
||||
NEW_COMMAND,
|
||||
READY,
|
||||
BAD_COMMAND
|
||||
BAD_COMMAND,
|
||||
}
|
||||
|
@ -8,17 +8,8 @@
|
||||
|
||||
package com.maddyhome.idea.vim.common
|
||||
|
||||
import com.maddyhome.idea.vim.api.ImmutableVimCaret
|
||||
import com.maddyhome.idea.vim.api.LineDeleteShift
|
||||
import com.maddyhome.idea.vim.api.MutableVimEditor
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.getLineEndOffset
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.api.setChangeMarks
|
||||
import com.maddyhome.idea.vim.api.toType
|
||||
import com.maddyhome.idea.vim.mark.VimMarkConstants
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
public data class Offset(val point: Int)
|
||||
public data class Pointer(val point: Int)
|
||||
|
@ -34,4 +34,4 @@ public fun VimLogger.debug(message: () -> String) {
|
||||
}
|
||||
}
|
||||
|
||||
inline public fun <reified T : Any> vimLogger(): VimLogger = injector.getLogger(T::class.java)
|
||||
public inline fun <reified T : Any> vimLogger(): VimLogger = injector.getLogger(T::class.java)
|
||||
|
@ -85,7 +85,7 @@ public sealed class Range(
|
||||
} else if (str == "%") {
|
||||
return arrayOf(
|
||||
LineNumberRange(0, 0, move),
|
||||
LineNumberRange(LineNumberRange.LAST_LINE, offset, move)
|
||||
LineNumberRange(LineNumberRange.LAST_LINE, offset, move),
|
||||
)
|
||||
} else if (str == "$") {
|
||||
return arrayOf(LineNumberRange(LineNumberRange.LAST_LINE, offset, move))
|
||||
|
@ -140,7 +140,7 @@ public class Ranges {
|
||||
endLine = range.getLine(editor, lastZero)
|
||||
if (range.isMove) {
|
||||
editor.primaryCaret().moveToOffset(
|
||||
injector.motion.moveCaretToLineWithSameColumn(editor, endLine, editor.primaryCaret())
|
||||
injector.motion.moveCaretToLineWithSameColumn(editor, endLine, editor.primaryCaret()),
|
||||
)
|
||||
}
|
||||
// Did that last range represent the start of the file?
|
||||
@ -161,9 +161,11 @@ public class Ranges {
|
||||
for (range in ranges) {
|
||||
startLine = endLine
|
||||
endLine = range.getLine(editor, caret, lastZero)
|
||||
if (range.isMove) caret.moveToOffset(
|
||||
injector.motion.moveCaretToLineWithSameColumn(editor, endLine, editor.primaryCaret())
|
||||
)
|
||||
if (range.isMove) {
|
||||
caret.moveToOffset(
|
||||
injector.motion.moveCaretToLineWithSameColumn(editor, endLine, editor.primaryCaret()),
|
||||
)
|
||||
}
|
||||
lastZero = endLine < 0
|
||||
++count
|
||||
}
|
||||
|
@ -152,7 +152,9 @@ public val ImmutableVimCaret.vimLeadSelectionOffset: Int
|
||||
if (caretLine == selectionStartLine) {
|
||||
val column = editor.offsetToBufferPosition(selectionEnd).column
|
||||
if (column == 0) (selectionEnd - 1).coerceAtLeast(0) else selectionEnd
|
||||
} else selectionStart
|
||||
} else {
|
||||
selectionStart
|
||||
}
|
||||
} else if (editor.inBlockSubMode) {
|
||||
val selections = editor.nativeCarets().map { it.selectionStart to it.selectionEnd }.sortedBy { it.first }
|
||||
val pCaret = editor.primaryCaret()
|
||||
|
@ -43,10 +43,12 @@ public object VisualOperation {
|
||||
|
||||
val chars = if (editor.primaryCaret().vimLastColumn == VimMotionGroupBase.LAST_COLUMN) {
|
||||
VimMotionGroupBase.LAST_COLUMN
|
||||
} else when (type) {
|
||||
SelectionType.LINE_WISE -> ep.column
|
||||
SelectionType.CHARACTER_WISE -> if (lines > 1) ep.column - injector.visualMotionGroup.selectionAdj else ep.column - sp.column
|
||||
SelectionType.BLOCK_WISE -> ep.column - sp.column + 1
|
||||
} else {
|
||||
when (type) {
|
||||
SelectionType.LINE_WISE -> ep.column
|
||||
SelectionType.CHARACTER_WISE -> if (lines > 1) ep.column - injector.visualMotionGroup.selectionAdj else ep.column - sp.column
|
||||
SelectionType.BLOCK_WISE -> ep.column - sp.column + 1
|
||||
}
|
||||
}
|
||||
|
||||
return VisualChange(lines, chars, type)
|
||||
|
@ -108,7 +108,7 @@ public sealed class ChangeEditorActionHandler : EditorActionHandlerBase(false) {
|
||||
worked[0] = false
|
||||
}
|
||||
},
|
||||
true
|
||||
true,
|
||||
)
|
||||
}
|
||||
is SingleExecution -> {
|
||||
@ -124,7 +124,7 @@ public sealed class ChangeEditorActionHandler : EditorActionHandlerBase(false) {
|
||||
worked[0] = false
|
||||
}
|
||||
},
|
||||
true
|
||||
true,
|
||||
)
|
||||
} else {
|
||||
worked[0] = execute(editor, context, cmd.argument, operatorArguments)
|
||||
|
@ -98,9 +98,11 @@ public abstract class EditorActionHandlerBase(private val myRunForEachCaret: Boo
|
||||
caret,
|
||||
injector.executionContextManager.onCaret(caret, context),
|
||||
cmd,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
) injector.messages.indicateError()
|
||||
) {
|
||||
injector.messages.indicateError()
|
||||
}
|
||||
}
|
||||
|
||||
public open fun process(cmd: Command) {
|
||||
|
@ -23,10 +23,10 @@ import com.maddyhome.idea.vim.command.MotionType
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.diagnostic.VimLogger
|
||||
import com.maddyhome.idea.vim.diagnostic.vimLogger
|
||||
import com.maddyhome.idea.vim.helper.StrictMode
|
||||
import com.maddyhome.idea.vim.helper.inBlockSubMode
|
||||
import com.maddyhome.idea.vim.helper.inVisualMode
|
||||
import com.maddyhome.idea.vim.helper.isEndAllowed
|
||||
import com.maddyhome.idea.vim.helper.StrictMode
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
@ -75,7 +75,7 @@ public sealed class MotionActionHandler : EditorActionHandlerBase(false) {
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Motion
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ public sealed class MotionActionHandler : EditorActionHandlerBase(false) {
|
||||
caret,
|
||||
context,
|
||||
cmd,
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
}
|
||||
} finally {
|
||||
@ -151,7 +151,7 @@ public sealed class MotionActionHandler : EditorActionHandlerBase(false) {
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
) {
|
||||
val offset = getOffset(editor, caret, context, cmd.argument, operatorArguments)
|
||||
when (offset) {
|
||||
@ -200,7 +200,7 @@ public sealed class MotionActionHandler : EditorActionHandlerBase(false) {
|
||||
private fun prepareMoveToAbsoluteOffset(
|
||||
editor: VimEditor,
|
||||
cmd: Command,
|
||||
offset: Motion.AbsoluteOffset
|
||||
offset: Motion.AbsoluteOffset,
|
||||
): Int {
|
||||
var resultOffset = offset.offset
|
||||
if (resultOffset < 0) {
|
||||
|
@ -80,7 +80,7 @@ public sealed class VimActionHandler(myRunForEachCaret: Boolean) : EditorActionH
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return when (this) {
|
||||
is ForEachCaret -> execute(editor, caret, context, cmd, operatorArguments)
|
||||
|
@ -113,7 +113,7 @@ public sealed class VisualOperatorActionHandler : EditorActionHandlerBase(false)
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
operatorArguments: OperatorArguments
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
logger.info("Execute visual command $cmd")
|
||||
|
||||
@ -147,7 +147,7 @@ public sealed class VisualOperatorActionHandler : EditorActionHandlerBase(false)
|
||||
context,
|
||||
cmd,
|
||||
selections.values.first(),
|
||||
operatorArguments
|
||||
operatorArguments,
|
||||
)
|
||||
else -> editor.forEachNativeCaret(
|
||||
{ currentCaret ->
|
||||
@ -155,7 +155,7 @@ public sealed class VisualOperatorActionHandler : EditorActionHandlerBase(false)
|
||||
val loopRes = executeAction(editor, currentCaret, context, cmd, range, operatorArguments)
|
||||
res[0] = loopRes and res[0]
|
||||
},
|
||||
true
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
@ -184,8 +184,9 @@ public sealed class VisualOperatorActionHandler : EditorActionHandlerBase(false)
|
||||
primaryCaret to VimBlockSelection(
|
||||
primaryCaret.offset.point,
|
||||
end,
|
||||
this, range.columns >= VimMotionGroupBase.LAST_COLUMN
|
||||
)
|
||||
this,
|
||||
range.columns >= VimMotionGroupBase.LAST_COLUMN,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
val carets = mutableMapOf<VimCaret, VimSelection>()
|
||||
@ -203,8 +204,9 @@ public sealed class VisualOperatorActionHandler : EditorActionHandlerBase(false)
|
||||
primaryCaret to VimBlockSelection(
|
||||
primaryCaret.vimSelectionStart,
|
||||
primaryCaret.offset.point,
|
||||
this, primaryCaret.vimLastColumn >= VimMotionGroupBase.LAST_COLUMN
|
||||
)
|
||||
this,
|
||||
primaryCaret.vimLastColumn >= VimMotionGroupBase.LAST_COLUMN,
|
||||
),
|
||||
)
|
||||
}
|
||||
else -> this.nativeCarets().associateWith { caret ->
|
||||
@ -215,7 +217,7 @@ public sealed class VisualOperatorActionHandler : EditorActionHandlerBase(false)
|
||||
caret.selectionStart,
|
||||
caret.selectionEnd,
|
||||
SelectionType.fromSubMode(subMode),
|
||||
this
|
||||
this,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -224,7 +226,7 @@ public sealed class VisualOperatorActionHandler : EditorActionHandlerBase(false)
|
||||
private class VisualStartFinishWrapper(
|
||||
private val editor: VimEditor,
|
||||
private val cmd: Command,
|
||||
private val visualOperatorActionHandler: VisualOperatorActionHandler
|
||||
private val visualOperatorActionHandler: VisualOperatorActionHandler,
|
||||
) {
|
||||
private val visualChanges = mutableMapOf<VimCaret, VisualChange?>()
|
||||
|
||||
@ -236,7 +238,9 @@ public sealed class VisualOperatorActionHandler : EditorActionHandlerBase(false)
|
||||
val change =
|
||||
if (this@VisualStartFinishWrapper.editor.inVisualMode && !this@VisualStartFinishWrapper.editor.inRepeatMode) {
|
||||
VisualOperation.getRange(this@VisualStartFinishWrapper.editor, it, this@VisualStartFinishWrapper.cmd.flags)
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
this@VisualStartFinishWrapper.visualChanges[it] = change
|
||||
}
|
||||
logger.debug { visualChanges.values.joinToString("\n") { "Caret: $visualChanges" } }
|
||||
|
@ -11,10 +11,13 @@ package com.maddyhome.idea.vim.history
|
||||
public object HistoryConstants {
|
||||
@JvmField
|
||||
public val SEARCH: String = "search"
|
||||
|
||||
@JvmField
|
||||
public val COMMAND: String = "cmd"
|
||||
|
||||
@JvmField
|
||||
public val EXPRESSION: String = "expr"
|
||||
|
||||
@JvmField
|
||||
public val INPUT: String = "input"
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class KeyMapping : Iterable<List<KeyStroke?>?>, KeyMappingLayer {
|
||||
fromKeys: List<KeyStroke>,
|
||||
owner: MappingOwner,
|
||||
extensionHandler: ExtensionHandler,
|
||||
recursive: Boolean
|
||||
recursive: Boolean,
|
||||
) {
|
||||
myKeys[ArrayList(fromKeys)] = ToHandlerMappingInfo(extensionHandler, fromKeys, recursive, owner)
|
||||
fillPrefixes(fromKeys)
|
||||
@ -69,7 +69,7 @@ public class KeyMapping : Iterable<List<KeyStroke?>?>, KeyMappingLayer {
|
||||
fromKeys: List<KeyStroke>,
|
||||
toKeys: List<KeyStroke>,
|
||||
owner: MappingOwner,
|
||||
recursive: Boolean
|
||||
recursive: Boolean,
|
||||
) {
|
||||
myKeys[ArrayList(fromKeys)] = ToKeysMappingInfo(toKeys, fromKeys, recursive, owner)
|
||||
fillPrefixes(fromKeys)
|
||||
@ -80,7 +80,7 @@ public class KeyMapping : Iterable<List<KeyStroke?>?>, KeyMappingLayer {
|
||||
toExpression: Expression,
|
||||
owner: MappingOwner,
|
||||
originalString: String,
|
||||
recursive: Boolean
|
||||
recursive: Boolean,
|
||||
) {
|
||||
myKeys[ArrayList(fromKeys)] =
|
||||
ToExpressionMappingInfo(toExpression, fromKeys, recursive, owner, originalString)
|
||||
@ -103,9 +103,10 @@ public class KeyMapping : Iterable<List<KeyStroke?>?>, KeyMappingLayer {
|
||||
toRemove.forEach(
|
||||
Consumer { (key, value): Map.Entry<List<KeyStroke>, MappingInfo> ->
|
||||
myKeys.remove(
|
||||
key, value
|
||||
key,
|
||||
value,
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
toRemove.map { it.key }.forEach(this::removePrefixes)
|
||||
}
|
||||
@ -139,7 +140,8 @@ public class KeyMapping : Iterable<List<KeyStroke?>?>, KeyMappingLayer {
|
||||
.filter { (_, value): Map.Entry<List<KeyStroke>, MappingInfo> -> value.owner == owner }
|
||||
.map { (key, value): Map.Entry<List<KeyStroke>, MappingInfo> ->
|
||||
Pair(
|
||||
key, value
|
||||
key,
|
||||
value,
|
||||
)
|
||||
}.collect(Collectors.toList())
|
||||
}
|
||||
@ -166,7 +168,8 @@ public class KeyMapping : Iterable<List<KeyStroke?>?>, KeyMappingLayer {
|
||||
.filter { (_, value): Map.Entry<List<KeyStroke>, MappingInfo> -> value is ToKeysMappingInfo && value.toKeys == toKeys }
|
||||
.map { (key, value): Map.Entry<List<KeyStroke>, MappingInfo> ->
|
||||
Pair(
|
||||
key, value
|
||||
key,
|
||||
value,
|
||||
)
|
||||
}.collect(Collectors.toList())
|
||||
}
|
||||
|
@ -166,7 +166,11 @@ public class ToHandlerMappingInfo(
|
||||
injector.application.invokeLater {
|
||||
KeyHandler.getInstance().finishedCommandPreparation(
|
||||
editor,
|
||||
context, VimStateMachine.getInstance(editor), VimStateMachine.getInstance(editor).commandBuilder, null, false
|
||||
context,
|
||||
VimStateMachine.getInstance(editor),
|
||||
VimStateMachine.getInstance(editor).commandBuilder,
|
||||
null,
|
||||
false,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -175,8 +179,10 @@ public class ToHandlerMappingInfo(
|
||||
|
||||
val operatorArguments = OperatorArguments(vimStateMachine.isOperatorPending, vimStateMachine.commandBuilder.count, vimStateMachine.mode, vimStateMachine.subMode)
|
||||
injector.actionExecutor.executeCommand(
|
||||
editor, { extensionHandler.execute(editor, context, operatorArguments) },
|
||||
"Vim " + extensionHandler.javaClass.simpleName, null
|
||||
editor,
|
||||
{ extensionHandler.execute(editor, context, operatorArguments) },
|
||||
"Vim " + extensionHandler.javaClass.simpleName,
|
||||
null,
|
||||
)
|
||||
|
||||
if (extensionHandler.isRepeatable) {
|
||||
|
@ -102,7 +102,7 @@ public sealed class ShortcutOwnerInfo {
|
||||
"i" to 2,
|
||||
"x" to 3,
|
||||
"s" to 4,
|
||||
"v" to 5
|
||||
"v" to 5,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -110,7 +110,8 @@ public sealed class ShortcutOwnerInfo {
|
||||
public enum class ShortcutOwner(public val ownerName: @NonNls String, private val title: @NonNls String) {
|
||||
UNDEFINED("undefined", "Undefined"),
|
||||
IDE(Constants.IDE_STRING, "IDE"),
|
||||
VIM(Constants.VIM_STRING, "Vim");
|
||||
VIM(Constants.VIM_STRING, "Vim"),
|
||||
;
|
||||
|
||||
override fun toString(): String = title
|
||||
|
||||
|
@ -46,6 +46,6 @@ public interface VimMacro {
|
||||
public fun playbackLastRegister(
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
count: Int
|
||||
count: Int,
|
||||
): Boolean
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public data class VimMark(
|
||||
line ?: return null,
|
||||
col ?: 0,
|
||||
filename ?: return null,
|
||||
protocol ?: ""
|
||||
protocol ?: "",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -172,4 +172,4 @@ public fun Option<out VimDataType>.removeValue(currentValue: VimDataType, value:
|
||||
is NumberOption -> this.subtractValues(currentValue as VimInt, value as VimInt)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public object GuiCursorOptionHelper {
|
||||
modes.addAll(
|
||||
modeList.split('-').map {
|
||||
GuiCursorMode.fromString(it) ?: throw exExceptionMessage("E546", token)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
var type: GuiCursorType? = null
|
||||
@ -124,7 +124,8 @@ public enum class GuiCursorMode(public val token: String) {
|
||||
CMD_LINE_INSERT("ci"),
|
||||
CMD_LINE_REPLACE("cr"),
|
||||
SHOW_MATCH("sm"),
|
||||
ALL("a");
|
||||
ALL("a"),
|
||||
;
|
||||
|
||||
public override fun toString(): String = token
|
||||
|
||||
@ -159,7 +160,7 @@ public enum class GuiCursorMode(public val token: String) {
|
||||
public enum class GuiCursorType(public val token: String) {
|
||||
BLOCK("block"),
|
||||
VER("ver"),
|
||||
HOR("hor")
|
||||
HOR("hor"),
|
||||
}
|
||||
|
||||
public class GuiCursorEntry(
|
||||
@ -169,7 +170,7 @@ public class GuiCursorEntry(
|
||||
public val thickness: Int?,
|
||||
public val highlightGroup: String,
|
||||
public val lmapHighlightGroup: String,
|
||||
public val blinkModes: List<String>
|
||||
public val blinkModes: List<String>,
|
||||
) {
|
||||
public override fun toString(): String {
|
||||
// We need to match the original string for output and remove purposes
|
||||
@ -182,5 +183,5 @@ public data class GuiCursorAttributes(
|
||||
val thickness: Int,
|
||||
val highlightGroup: String,
|
||||
val lmapHighlightGroup: String,
|
||||
val blinkModes: List<String>
|
||||
val blinkModes: List<String>,
|
||||
)
|
||||
|
@ -29,7 +29,7 @@ public object KeywordOptionHelper {
|
||||
|
||||
public fun updateSpecs() {
|
||||
keywordSpecs = valuesToValidatedAndReversedSpecs(
|
||||
parseValues(injector.globalOptions().getStringValue(OptionConstants.iskeyword))
|
||||
parseValues(injector.globalOptions().getStringValue(OptionConstants.iskeyword)),
|
||||
)!!.toMutableList()
|
||||
}
|
||||
|
||||
@ -188,7 +188,9 @@ public object KeywordOptionHelper {
|
||||
}
|
||||
return if (isRange) {
|
||||
code >= rangeLow!! && code <= rangeHigh!!
|
||||
} else code == rangeLow
|
||||
} else {
|
||||
code == rangeLow
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public interface VimPut {
|
||||
public fun doIndent(editor: VimEditor, caret: VimCaret, context: ExecutionContext, startOffset: Int, endOffset: Int): Int
|
||||
|
||||
public fun notifyAboutIdeaPut(editor: VimEditor?)
|
||||
|
||||
@RWLockLabel.SelfSynchronized
|
||||
public fun putTextAndSetCaretPosition(
|
||||
editor: VimEditor,
|
||||
|
@ -76,9 +76,11 @@ public abstract class VimPutBase : VimPut {
|
||||
mapOf(
|
||||
"startColumnOfSelection" to min(selStart.column, selEnd.column),
|
||||
"selectedLines" to abs(selStart.line - selEnd.line),
|
||||
"firstSelectedLine" to min(selStart.line, selEnd.line)
|
||||
"firstSelectedLine" to min(selStart.line, selEnd.line),
|
||||
)
|
||||
} else mutableMapOf()
|
||||
} else {
|
||||
mutableMapOf()
|
||||
}
|
||||
}
|
||||
|
||||
private fun wasTextInsertedLineWise(text: ProcessedTextData): Boolean {
|
||||
@ -132,8 +134,10 @@ public abstract class VimPutBase : VimPut {
|
||||
|
||||
if (data.textData.typeInRegister.isLine && text.isNotEmpty() && text.last() != '\n') text += '\n'
|
||||
|
||||
if (data.textData.typeInRegister.isChar && text.lastOrNull() == '\n' && data.visualSelection?.typeInEditor?.isLine == false) text =
|
||||
text.dropLast(1)
|
||||
if (data.textData.typeInRegister.isChar && text.lastOrNull() == '\n' && data.visualSelection?.typeInEditor?.isLine == false) {
|
||||
text =
|
||||
text.dropLast(1)
|
||||
}
|
||||
|
||||
return ProcessedTextData(text, data.textData.typeInRegister, data.textData.transferableData)
|
||||
}
|
||||
@ -230,19 +234,19 @@ public abstract class VimPutBase : VimPut {
|
||||
if (possiblyOverlappedCaret.offset.point != startOffset || possiblyOverlappedCaret == caret) continue
|
||||
|
||||
val updated = possiblyOverlappedCaret.moveToMotion(
|
||||
injector.motion.getHorizontalMotion(editor, possiblyOverlappedCaret, 1, true)
|
||||
injector.motion.getHorizontalMotion(editor, possiblyOverlappedCaret, 1, true),
|
||||
)
|
||||
overlappedCarets.add(updated)
|
||||
}
|
||||
|
||||
val endOffset = putTextCharacterwise(
|
||||
editor, caret, context, text, type, mode, startOffset, count, indent,
|
||||
cursorAfter
|
||||
cursorAfter,
|
||||
)
|
||||
|
||||
for (overlappedCaret in overlappedCarets) {
|
||||
overlappedCaret.moveToMotion(
|
||||
injector.motion.getHorizontalMotion(editor, overlappedCaret, -1, true)
|
||||
injector.motion.getHorizontalMotion(editor, overlappedCaret, -1, true),
|
||||
)
|
||||
}
|
||||
|
||||
@ -352,7 +356,7 @@ public abstract class VimPutBase : VimPut {
|
||||
startOffset,
|
||||
count,
|
||||
indent,
|
||||
cursorAfter
|
||||
cursorAfter,
|
||||
)
|
||||
SelectionType.LINE_WISE -> putTextLinewise(
|
||||
editor,
|
||||
@ -364,7 +368,7 @@ public abstract class VimPutBase : VimPut {
|
||||
startOffset,
|
||||
count,
|
||||
indent,
|
||||
cursorAfter
|
||||
cursorAfter,
|
||||
)
|
||||
else -> putTextBlockwise(editor, caret, context, text, type, mode, startOffset, count, indent, cursorAfter)
|
||||
}
|
||||
@ -407,9 +411,9 @@ public abstract class VimPutBase : VimPut {
|
||||
vimEditor.bufferPositionToOffset(
|
||||
BufferPosition(
|
||||
firstSelectedLine,
|
||||
startColumnOfSelection
|
||||
)
|
||||
)
|
||||
startColumnOfSelection,
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -422,7 +426,9 @@ public abstract class VimPutBase : VimPut {
|
||||
if (vimCaret.offset.point == vimEditor.fileSize().toInt() && vimEditor.fileSize().toInt() != 0 && lastChar != '\n') {
|
||||
application.runWriteAction { (vimEditor as MutableVimEditor).insertText(vimCaret.offset, "\n") }
|
||||
listOf(vimCaret.offset.point + 1)
|
||||
} else listOf(vimCaret.offset.point)
|
||||
} else {
|
||||
listOf(vimCaret.offset.point)
|
||||
}
|
||||
}
|
||||
else -> listOf(vimCaret.offset.point)
|
||||
}
|
||||
@ -480,7 +486,7 @@ public abstract class VimPutBase : VimPut {
|
||||
val subMode = data.visualSelection?.typeInEditor?.toSubMode() ?: VimStateMachine.SubMode.NONE
|
||||
val (endOffset, updatedCaret) = putTextInternal(
|
||||
editor, updated, context, text.text, text.typeInRegister, subMode,
|
||||
startOffset, data.count, data.indent, data.caretAfterInsertedText
|
||||
startOffset, data.count, data.indent, data.caretAfterInsertedText,
|
||||
)
|
||||
updated = updatedCaret
|
||||
injector.markService.setChangeMarks(updatedCaret, TextRange(startOffset, endOffset))
|
||||
@ -491,7 +497,7 @@ public abstract class VimPutBase : VimPut {
|
||||
endOffset,
|
||||
text.typeInRegister,
|
||||
subMode,
|
||||
data.caretAfterInsertedText
|
||||
data.caretAfterInsertedText,
|
||||
)
|
||||
}
|
||||
return updated
|
||||
@ -505,7 +511,7 @@ public abstract class VimPutBase : VimPut {
|
||||
editor,
|
||||
data,
|
||||
OperatorArguments(false, 0, editor.mode, editor.subMode),
|
||||
modifyRegister
|
||||
modifyRegister,
|
||||
)
|
||||
}
|
||||
val processedText = processText(editor, caret, data) ?: return false
|
||||
|
@ -62,17 +62,19 @@ public class CharPointer {
|
||||
public fun charAt(offset: Int = 0): Char {
|
||||
return if (end(offset)) {
|
||||
'\u0000'
|
||||
} else seq[pointer + offset]
|
||||
} else {
|
||||
seq[pointer + offset]
|
||||
}
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
operator public fun inc(cnt: Int = 1): CharPointer {
|
||||
public operator fun inc(cnt: Int = 1): CharPointer {
|
||||
pointer += cnt
|
||||
return this
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
operator public fun dec(cnt: Int = 1): CharPointer {
|
||||
public operator fun dec(cnt: Int = 1): CharPointer {
|
||||
pointer -= cnt
|
||||
return this
|
||||
}
|
||||
@ -126,8 +128,12 @@ public class CharPointer {
|
||||
for (i in 0 until l) {
|
||||
val c1 = cs1[i]
|
||||
val c2 = cs2[i]
|
||||
val notEqual = if (ignoreCase) c1.lowercaseChar() != c2.lowercaseChar() &&
|
||||
c1.uppercaseChar() != c2.uppercaseChar() else c1 != c2
|
||||
val notEqual = if (ignoreCase) {
|
||||
c1.lowercaseChar() != c2.lowercaseChar() &&
|
||||
c1.uppercaseChar() != c2.uppercaseChar()
|
||||
} else {
|
||||
c1 != c2
|
||||
}
|
||||
if (notEqual) return 1
|
||||
}
|
||||
return 0
|
||||
@ -208,7 +214,7 @@ public class CharPointer {
|
||||
return seq[pointer + 7]
|
||||
}
|
||||
|
||||
override public fun equals(obj: Any?): Boolean {
|
||||
public override fun equals(obj: Any?): Boolean {
|
||||
if (obj is CharPointer) {
|
||||
val ptr = obj
|
||||
return ptr.seq === seq && ptr.pointer == pointer
|
||||
@ -216,7 +222,7 @@ public class CharPointer {
|
||||
return false
|
||||
}
|
||||
|
||||
override public fun hashCode(): Int {
|
||||
public override fun hashCode(): Int {
|
||||
return Objects.hash(seq, pointer)
|
||||
}
|
||||
|
||||
@ -238,7 +244,7 @@ public class CharPointer {
|
||||
return Math.min(seq.length, pos)
|
||||
}
|
||||
|
||||
override public fun toString(): String {
|
||||
public override fun toString(): String {
|
||||
return substring(strlen())
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user