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