mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-13 23:17:06 +02:00
Moved some actions from change.change package
This commit is contained in:
src
main
java
com
maddyhome
idea
vim
action
change
Extension.ktRepeatChangeAction.kt
change
delete
DeleteCharacterAction.ktDeleteEndOfLineAction.ktDeleteJoinLinesAction.ktDeleteJoinLinesSpacesAction.ktDeleteJoinVisualLinesAction.ktDeleteJoinVisualLinesSpacesAction.ktDeleteMotionAction.ktDeleteVisualAction.ktDeleteVisualLinesAction.ktDeleteVisualLinesEndAction.kt
insert
InsertAfterCursorAction.ktInsertAfterLineEndAction.ktInsertAtPreviousInsertAction.ktInsertBeforeCursorAction.ktInsertBeforeFirstNonBlankAction.ktInsertCharacterAboveCursorAction.ktInsertCharacterBelowCursorAction.ktInsertDeleteInsertedTextAction.ktInsertDeletePreviousWordAction.ktInsertEnterAction.ktInsertInsertAction.ktInsertLineStartAction.ktInsertNewLineBelowAction.ktInsertPreviousInsertAction.ktInsertPreviousInsertExitAction.ktInsertRegisterAction.ktInsertSingleCommandAction.ktVisualBlockAppendAction.ktVisualBlockInsertAction.kt
shift
copy
motion
select
ex
ranges
extension
group
helper
key
listener
newapi
option
vimscript
test
java
org
jetbrains
plugins
ideavim
option
vim-engine
build.gradle
src
main
kotlin
com
maddyhome
idea
vim
action
change
VimRepeater.kt
change
AutoIndentLinesVisualAction.ktChangeCaseLowerMotionAction.ktChangeCaseLowerVisualAction.ktChangeCaseToggleCharacterAction.ktChangeCaseToggleMotionAction.ktChangeCaseToggleVisualAction.ktChangeCaseUpperMotionAction.ktChangeCaseUpperVisualAction.ktChangeCharacterAction.ktChangeCharactersAction.ktChangeEndOfLineAction.ktChangeLineAction.ktChangeMotionAction.ktChangeReplaceAction.ktChangeVisualAction.ktChangeVisualCharacterAction.ktChangeVisualLinesAction.ktChangeVisualLinesEndAction.ktFilterMotionAction.ktFilterVisualLinesAction.ktReformatCodeMotionAction.ktReformatCodeVisualAction.kt
number
api
EngineEditorHelper.ktVimCaret.ktVimChangeGroup.ktVimChangeGroupBase.ktVimEditor.ktVimInjector.ktVimMotionGroup.ktVimProcessGroup.kt
ex
ranges
group
handler
helper
options
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2022 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.maddyhome.idea.vim.action.change
|
||||
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionHandler
|
||||
import javax.swing.KeyStroke
|
||||
|
||||
object Extension {
|
||||
var lastExtensionHandler: VimExtensionHandler? = null
|
||||
|
||||
private val keyStrokes = mutableListOf<KeyStroke>()
|
||||
private val strings = mutableListOf<String>()
|
||||
|
||||
private var keystrokePointer = 0
|
||||
private var stringPointer = 0
|
||||
|
||||
fun addKeystroke(key: KeyStroke) = keyStrokes.add(key)
|
||||
fun addString(key: String) = strings.add(key)
|
||||
|
||||
fun consumeKeystroke(): KeyStroke? {
|
||||
if (keystrokePointer in keyStrokes.indices) {
|
||||
keystrokePointer += 1
|
||||
return keyStrokes[keystrokePointer - 1]
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun consumeString(): String? {
|
||||
if (stringPointer in strings.indices) {
|
||||
stringPointer += 1
|
||||
return strings[stringPointer - 1]
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
keystrokePointer = 0
|
||||
stringPointer = 0
|
||||
}
|
||||
|
||||
fun clean() {
|
||||
keyStrokes.clear()
|
||||
strings.clear()
|
||||
keystrokePointer = 0
|
||||
stringPointer = 0
|
||||
}
|
||||
}
|
@@ -24,11 +24,9 @@ import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.extension.VimExtensionHandler
|
||||
import com.maddyhome.idea.vim.handler.VimActionHandler
|
||||
import com.maddyhome.idea.vim.helper.commandState
|
||||
import com.maddyhome.idea.vim.newapi.ij
|
||||
import javax.swing.KeyStroke
|
||||
|
||||
class RepeatChangeAction : VimActionHandler.SingleExecution() {
|
||||
override val type: Command.Type = Command.Type.OTHER_WRITABLE
|
||||
@@ -37,14 +35,14 @@ class RepeatChangeAction : VimActionHandler.SingleExecution() {
|
||||
val state = editor.commandState
|
||||
val lastCommand = VimRepeater.lastChangeCommand
|
||||
|
||||
if (lastCommand == null && VimRepeater.Extension.lastExtensionHandler == null) return false
|
||||
if (lastCommand == null && Extension.lastExtensionHandler == null) return false
|
||||
|
||||
// Save state
|
||||
val save = state.executingCommand
|
||||
val lastFTCmd = VimPlugin.getMotion().lastFTCmd
|
||||
val lastFTChar = VimPlugin.getMotion().lastFTChar
|
||||
val reg = VimPlugin.getRegister().currentRegister
|
||||
val lastHandler = VimRepeater.Extension.lastExtensionHandler
|
||||
val lastHandler = Extension.lastExtensionHandler
|
||||
val repeatHandler = VimRepeater.repeatHandler
|
||||
|
||||
state.isDotRepeatInProgress = true
|
||||
@@ -83,65 +81,10 @@ class RepeatChangeAction : VimActionHandler.SingleExecution() {
|
||||
// Restore state
|
||||
if (save != null) state.setExecutingCommand(save)
|
||||
VimPlugin.getMotion().setLastFTCmd(lastFTCmd, lastFTChar)
|
||||
if (lastHandler != null) VimRepeater.Extension.lastExtensionHandler = lastHandler
|
||||
if (lastHandler != null) Extension.lastExtensionHandler = lastHandler
|
||||
VimRepeater.repeatHandler = repeatHandler
|
||||
VimRepeater.Extension.reset()
|
||||
Extension.reset()
|
||||
VimPlugin.getRegister().selectRegister(reg)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
object VimRepeater {
|
||||
var repeatHandler = false
|
||||
|
||||
var lastChangeCommand: Command? = null
|
||||
private set
|
||||
var lastChangeRegister = VimPlugin.getRegister().defaultRegister
|
||||
private set
|
||||
|
||||
fun saveLastChange(command: Command) {
|
||||
lastChangeCommand = command
|
||||
lastChangeRegister = VimPlugin.getRegister().currentRegister
|
||||
}
|
||||
|
||||
object Extension {
|
||||
var lastExtensionHandler: VimExtensionHandler? = null
|
||||
|
||||
private val keyStrokes = mutableListOf<KeyStroke>()
|
||||
private val strings = mutableListOf<String>()
|
||||
|
||||
private var keystrokePointer = 0
|
||||
private var stringPointer = 0
|
||||
|
||||
fun addKeystroke(key: KeyStroke) = keyStrokes.add(key)
|
||||
fun addString(key: String) = strings.add(key)
|
||||
|
||||
fun consumeKeystroke(): KeyStroke? {
|
||||
if (keystrokePointer in keyStrokes.indices) {
|
||||
keystrokePointer += 1
|
||||
return keyStrokes[keystrokePointer - 1]
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun consumeString(): String? {
|
||||
if (stringPointer in strings.indices) {
|
||||
stringPointer += 1
|
||||
return strings[stringPointer - 1]
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
keystrokePointer = 0
|
||||
stringPointer = 0
|
||||
}
|
||||
|
||||
fun clean() {
|
||||
keyStrokes.clear()
|
||||
strings.clear()
|
||||
keystrokePointer = 0
|
||||
stringPointer = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,28 +17,27 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.ex.ranges.LineRange
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.vimscript.model.Script
|
||||
|
||||
class ChangeLastGlobalSearchReplaceAction : ChangeEditorActionHandler.SingleExecution() {
|
||||
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
val range = LineRange(0, EditorHelper.getLineCount(editor) - 1)
|
||||
val range = LineRange(0, editor.lineCount() - 1)
|
||||
return VimPlugin.getSearch()
|
||||
.processSubstituteCommand(editor, editor.caretModel.primaryCaret, range, "s", "//~/&", Script(listOf()))
|
||||
.processSubstituteCommand(editor, editor.primaryCaret(), range, "s", "//~/&", Script(listOf()))
|
||||
}
|
||||
}
|
||||
|
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -31,14 +31,14 @@ class ChangeLastSearchReplaceAction : ChangeEditorActionHandler.SingleExecution(
|
||||
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
var result = true
|
||||
for (caret in editor.caretModel.allCarets) {
|
||||
val line = caret.logicalPosition.line
|
||||
for (caret in editor.carets()) {
|
||||
val line = caret.getLogicalPosition().line
|
||||
if (!VimPlugin.getSearch().processSubstituteCommand(editor, caret, LineRange(line, line), "s", "//~/", Script(listOf()))) {
|
||||
result = false
|
||||
}
|
||||
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.delete
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -34,9 +34,9 @@ abstract class DeleteCharacter(private val countModifier: (Int) -> Int) : Change
|
||||
override val type: Command.Type = Command.Type.DELETE
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.delete
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -30,9 +30,9 @@ class DeleteEndOfLineAction : ChangeEditorActionHandler.ForEachCaret() {
|
||||
override val type: Command.Type = Command.Type.DELETE
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
|
@@ -17,15 +17,16 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.delete
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.options.OptionConstants
|
||||
import com.maddyhome.idea.vim.options.OptionScope
|
||||
@@ -34,20 +35,20 @@ class DeleteJoinLinesAction : ChangeEditorActionHandler.SingleExecution() {
|
||||
override val type: Command.Type = Command.Type.DELETE
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
if (editor.isOneLineMode) return false
|
||||
if (VimPlugin.getOptionService().isSet(OptionScope.LOCAL(IjVimEditor(editor)), OptionConstants.ideajoinName)) {
|
||||
if ((editor as IjVimEditor).editor.isOneLineMode) return false
|
||||
if (VimPlugin.getOptionService().isSet(OptionScope.LOCAL(editor), OptionConstants.ideajoinName)) {
|
||||
return VimPlugin.getChange().joinViaIdeaByCount(editor, context, operatorArguments.count1)
|
||||
}
|
||||
VimPlugin.getEditor().notifyIdeaJoin(editor.project)
|
||||
VimPlugin.getEditor().notifyIdeaJoin(editor.editor.project)
|
||||
val res = Ref.create(true)
|
||||
editor.caretModel.runForEachCaret(
|
||||
editor.editor.caretModel.runForEachCaret(
|
||||
{ caret: Caret ->
|
||||
if (!VimPlugin.getChange().deleteJoinLines(editor, caret, operatorArguments.count1, false)) res.set(false)
|
||||
if (!VimPlugin.getChange().deleteJoinLines(editor, IjVimCaret(caret), operatorArguments.count1, false)) res.set(false)
|
||||
},
|
||||
true
|
||||
)
|
||||
|
@@ -17,15 +17,16 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.delete
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.options.OptionConstants
|
||||
import com.maddyhome.idea.vim.options.OptionScope
|
||||
@@ -34,20 +35,20 @@ class DeleteJoinLinesSpacesAction : ChangeEditorActionHandler.SingleExecution()
|
||||
override val type: Command.Type = Command.Type.DELETE
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
if (editor.isOneLineMode) return false
|
||||
if (VimPlugin.getOptionService().isSet(OptionScope.LOCAL(IjVimEditor(editor)), OptionConstants.ideajoinName)) {
|
||||
if ((editor as IjVimEditor).editor.isOneLineMode) return false
|
||||
if (VimPlugin.getOptionService().isSet(OptionScope.LOCAL(editor), OptionConstants.ideajoinName)) {
|
||||
return VimPlugin.getChange().joinViaIdeaByCount(editor, context, operatorArguments.count1)
|
||||
}
|
||||
VimPlugin.getEditor().notifyIdeaJoin(editor.project)
|
||||
VimPlugin.getEditor().notifyIdeaJoin(editor.editor.project)
|
||||
val res = Ref.create(true)
|
||||
editor.caretModel.runForEachCaret(
|
||||
editor.editor.caretModel.runForEachCaret(
|
||||
{ caret: Caret ->
|
||||
if (!VimPlugin.getChange().deleteJoinLines(editor, caret, operatorArguments.count1, true)) res.set(false)
|
||||
if (!VimPlugin.getChange().deleteJoinLines(editor, IjVimCaret(caret), operatorArguments.count1, true)) res.set(false)
|
||||
},
|
||||
true
|
||||
)
|
||||
|
@@ -17,17 +17,19 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.delete
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.group.visual.VimSelection
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.options.OptionConstants
|
||||
import com.maddyhome.idea.vim.options.OptionScope
|
||||
@@ -42,23 +44,23 @@ class DeleteJoinVisualLinesAction : VisualOperatorActionHandler.SingleExecution(
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeForAllCarets(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
caretsAndSelections: Map<Caret, VimSelection>,
|
||||
caretsAndSelections: Map<VimCaret, VimSelection>,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
if (editor.isOneLineMode) return false
|
||||
if (VimPlugin.getOptionService().isSet(OptionScope.LOCAL(IjVimEditor(editor)), OptionConstants.ideajoinName)) {
|
||||
if ((editor as IjVimEditor).editor.isOneLineMode) return false
|
||||
if (VimPlugin.getOptionService().isSet(OptionScope.LOCAL(editor), OptionConstants.ideajoinName)) {
|
||||
VimPlugin.getChange().joinViaIdeaBySelections(editor, context, caretsAndSelections)
|
||||
return true
|
||||
}
|
||||
val res = Ref.create(true)
|
||||
editor.caretModel.runForEachCaret(
|
||||
editor.editor.caretModel.runForEachCaret(
|
||||
{ caret: Caret ->
|
||||
if (!caret.isValid) return@runForEachCaret
|
||||
val range = caretsAndSelections[caret] ?: return@runForEachCaret
|
||||
if (!VimPlugin.getChange().deleteJoinRange(editor, caret, range.toVimTextRange(true).normalize(), false)) {
|
||||
val range = caretsAndSelections[IjVimCaret(caret)] ?: return@runForEachCaret
|
||||
if (!VimPlugin.getChange().deleteJoinRange(editor, IjVimCaret(caret), range.toVimTextRange(true).normalize(), false)) {
|
||||
res.set(false)
|
||||
}
|
||||
},
|
||||
|
@@ -17,17 +17,19 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.delete
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.util.Ref
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.group.visual.VimSelection
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.options.OptionConstants
|
||||
import com.maddyhome.idea.vim.options.OptionScope
|
||||
@@ -42,23 +44,23 @@ class DeleteJoinVisualLinesSpacesAction : VisualOperatorActionHandler.SingleExec
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeForAllCarets(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
caretsAndSelections: Map<Caret, VimSelection>,
|
||||
caretsAndSelections: Map<VimCaret, VimSelection>,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
if (editor.isOneLineMode) return false
|
||||
if (VimPlugin.getOptionService().isSet(OptionScope.LOCAL(IjVimEditor(editor)), OptionConstants.ideajoinName)) {
|
||||
if ((editor as IjVimEditor).editor.isOneLineMode) return false
|
||||
if (VimPlugin.getOptionService().isSet(OptionScope.LOCAL(editor), OptionConstants.ideajoinName)) {
|
||||
VimPlugin.getChange().joinViaIdeaBySelections(editor, context, caretsAndSelections)
|
||||
return true
|
||||
}
|
||||
val res = Ref.create(true)
|
||||
editor.caretModel.runForEachCaret(
|
||||
editor.editor.caretModel.runForEachCaret(
|
||||
{ caret: Caret ->
|
||||
if (!caret.isValid) return@runForEachCaret
|
||||
val range = caretsAndSelections[caret] ?: return@runForEachCaret
|
||||
if (!VimPlugin.getChange().deleteJoinRange(editor, caret, range.toVimTextRange(true).normalize(), true)) {
|
||||
val range = caretsAndSelections[IjVimCaret(caret)] ?: return@runForEachCaret
|
||||
if (!VimPlugin.getChange().deleteJoinRange(editor, IjVimCaret(caret), range.toVimTextRange(true).normalize(), true)) {
|
||||
res.set(false)
|
||||
}
|
||||
},
|
||||
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.delete
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.DuplicableOperatorAction
|
||||
@@ -37,9 +37,9 @@ class DeleteMotionAction : ChangeEditorActionHandler.ForEachCaret(), DuplicableO
|
||||
override val duplicateWith: Char = 'd'
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.delete
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -38,9 +38,9 @@ class DeleteVisualAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
|
@@ -17,10 +17,11 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.delete
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -28,9 +29,7 @@ import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.group.visual.VimSelection
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.helper.fileSize
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -42,22 +41,22 @@ class DeleteVisualLinesAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE, CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
val textRange = range.toVimTextRange(false)
|
||||
val (usedCaret, usedRange, usedType) = when (range.type) {
|
||||
SelectionType.BLOCK_WISE -> Triple(editor.caretModel.primaryCaret, textRange, range.type)
|
||||
SelectionType.BLOCK_WISE -> Triple(editor.primaryCaret(), textRange, range.type)
|
||||
SelectionType.LINE_WISE -> Triple(caret, textRange, SelectionType.LINE_WISE)
|
||||
SelectionType.CHARACTER_WISE -> {
|
||||
val lineEndForOffset = EditorHelper.getLineEndForOffset(editor, textRange.endOffset)
|
||||
val endsWithNewLine = if (lineEndForOffset == editor.fileSize) 0 else 1
|
||||
val lineEndForOffset = injector.engineEditorHelper.getLineEndForOffset(editor, textRange.endOffset)
|
||||
val endsWithNewLine = if (lineEndForOffset.toLong() == editor.fileSize()) 0 else 1
|
||||
val lineRange = TextRange(
|
||||
EditorHelper.getLineStartForOffset(editor, textRange.startOffset),
|
||||
injector.engineEditorHelper.getLineStartForOffset(editor, textRange.startOffset),
|
||||
lineEndForOffset + endsWithNewLine
|
||||
)
|
||||
Triple(caret, lineRange, SelectionType.LINE_WISE)
|
||||
|
@@ -17,10 +17,11 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.delete
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -28,9 +29,7 @@ import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.group.visual.VimSelection
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.helper.fileSize
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -42,9 +41,9 @@ class DeleteVisualLinesEndAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE, CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
@@ -55,17 +54,16 @@ class DeleteVisualLinesEndAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
val ends = vimTextRange.endOffsets
|
||||
for (i in starts.indices) {
|
||||
if (ends[i] > starts[i]) {
|
||||
ends[i] = EditorHelper.getLineEndForOffset(editor, starts[i])
|
||||
ends[i] = injector.engineEditorHelper.getLineEndForOffset(editor, starts[i])
|
||||
}
|
||||
}
|
||||
val blockRange = TextRange(starts, ends)
|
||||
VimPlugin.getChange()
|
||||
.deleteRange(editor, editor.caretModel.primaryCaret, blockRange, SelectionType.BLOCK_WISE, false)
|
||||
VimPlugin.getChange().deleteRange(editor, editor.primaryCaret(), blockRange, SelectionType.BLOCK_WISE, false)
|
||||
} else {
|
||||
val lineEndForOffset = EditorHelper.getLineEndForOffset(editor, vimTextRange.endOffset)
|
||||
val endsWithNewLine = if (lineEndForOffset == editor.fileSize) 0 else 1
|
||||
val lineEndForOffset = injector.engineEditorHelper.getLineEndForOffset(editor, vimTextRange.endOffset)
|
||||
val endsWithNewLine = if (lineEndForOffset.toLong() == editor.fileSize()) 0 else 1
|
||||
val lineRange = TextRange(
|
||||
EditorHelper.getLineStartForOffset(editor, vimTextRange.startOffset),
|
||||
injector.engineEditorHelper.getLineStartForOffset(editor, vimTextRange.startOffset),
|
||||
lineEndForOffset + endsWithNewLine
|
||||
)
|
||||
VimPlugin.getChange().deleteRange(editor, caret, lineRange, SelectionType.LINE_WISE, false)
|
||||
|
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -34,8 +34,8 @@ class InsertAfterCursorAction : ChangeEditorActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MULTIKEY_UNDO)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
|
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -34,8 +34,8 @@ class InsertAfterLineEndAction : ChangeEditorActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MULTIKEY_UNDO)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
|
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -34,8 +34,8 @@ class InsertAtPreviousInsertAction : ChangeEditorActionHandler.SingleExecution()
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MULTIKEY_UNDO)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
|
@@ -17,16 +17,15 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import org.jetbrains.annotations.Contract
|
||||
import java.util.*
|
||||
|
||||
@@ -37,12 +36,12 @@ class InsertBeforeCursorAction : ChangeEditorActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MULTIKEY_UNDO)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
VimPlugin.getChange().insertBeforeCursor(editor.vim, context.vim)
|
||||
VimPlugin.getChange().insertBeforeCursor(editor, context)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -34,8 +34,8 @@ class InsertBeforeFirstNonBlankAction : ChangeEditorActionHandler.SingleExecutio
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MULTIKEY_UNDO)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
|
@@ -17,26 +17,27 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
|
||||
class InsertCharacterAboveCursorAction : ChangeEditorActionHandler.ForEachCaret() {
|
||||
override val type: Command.Type = Command.Type.INSERT
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return if (editor.isOneLineMode) {
|
||||
return if ((editor as IjVimEditor).editor.isOneLineMode) {
|
||||
false
|
||||
} else VimPlugin.getChange().insertCharacterAroundCursor(editor, caret, -1)
|
||||
}
|
||||
|
@@ -17,26 +17,27 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
|
||||
class InsertCharacterBelowCursorAction : ChangeEditorActionHandler.ForEachCaret() {
|
||||
override val type: Command.Type = Command.Type.INSERT
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return if (editor.isOneLineMode) {
|
||||
return if ((editor as IjVimEditor).editor.isOneLineMode) {
|
||||
false
|
||||
} else VimPlugin.getChange().insertCharacterAroundCursor(editor, caret, 1)
|
||||
}
|
||||
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -35,9 +35,9 @@ class InsertDeleteInsertedTextAction : ChangeEditorActionHandler.ForEachCaret()
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_CLEAR_STROKES)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -35,9 +35,9 @@ class InsertDeletePreviousWordAction : ChangeEditorActionHandler.ForEachCaret()
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_CLEAR_STROKES)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
|
@@ -26,7 +26,6 @@ import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.group.MotionGroup
|
||||
import com.maddyhome.idea.vim.handler.VimActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.helper.getTopLevelEditor
|
||||
import com.maddyhome.idea.vim.newapi.ij
|
||||
import java.util.*
|
||||
|
||||
@@ -36,7 +35,7 @@ class InsertEnterAction : VimActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_SAVE_STROKE)
|
||||
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean {
|
||||
VimPlugin.getChange().processEnter(editor.ij.getTopLevelEditor(), context.ij)
|
||||
VimPlugin.getChange().processEnter(editor, context)
|
||||
MotionGroup.scrollCaretIntoView(editor.ij)
|
||||
return true
|
||||
}
|
||||
|
@@ -25,7 +25,6 @@ import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.handler.VimActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.newapi.ij
|
||||
import java.util.*
|
||||
|
||||
class InsertInsertAction : VimActionHandler.SingleExecution() {
|
||||
@@ -34,7 +33,7 @@ class InsertInsertAction : VimActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_SAVE_STROKE)
|
||||
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean {
|
||||
VimPlugin.getChange().processInsert(editor.ij)
|
||||
VimPlugin.getChange().processInsert(editor)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -34,8 +34,8 @@ class InsertLineStartAction : ChangeEditorActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MULTIKEY_UNDO)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
|
@@ -17,15 +17,16 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.newapi.insertLineAround
|
||||
import java.util.*
|
||||
|
||||
@@ -35,12 +36,12 @@ class InsertNewLineBelowAction : ChangeEditorActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MULTIKEY_UNDO)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
if (editor.isOneLineMode) return false
|
||||
if ((editor as IjVimEditor).editor.isOneLineMode) return false
|
||||
// if (experimentalApi()) {
|
||||
@Suppress("ConstantConditionIf")
|
||||
if (false) {
|
||||
@@ -58,12 +59,12 @@ class InsertNewLineAboveAction : ChangeEditorActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MULTIKEY_UNDO)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
if (editor.isOneLineMode) return false
|
||||
if ((editor as IjVimEditor).editor.isOneLineMode) return false
|
||||
// if (experimentalApi()) {
|
||||
@Suppress("ConstantConditionIf")
|
||||
if (false) {
|
||||
|
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -29,8 +29,8 @@ class InsertPreviousInsertAction : ChangeEditorActionHandler.SingleExecution() {
|
||||
override val type: Command.Type = Command.Type.INSERT
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.action.ComplicatedKeysAction
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -38,8 +38,8 @@ class InsertPreviousInsertExitAction : ChangeEditorActionHandler.SingleExecution
|
||||
override val type: Command.Type = Command.Type.INSERT
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
|
@@ -29,6 +29,8 @@ import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.ex.ExException
|
||||
import com.maddyhome.idea.vim.handler.VimActionHandler
|
||||
import com.maddyhome.idea.vim.helper.CommandLineHelper
|
||||
import com.maddyhome.idea.vim.newapi.IjExecutionContext
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.newapi.ij
|
||||
import com.maddyhome.idea.vim.vimscript.model.Script
|
||||
import com.maddyhome.idea.vim.vimscript.parser.VimscriptParser
|
||||
@@ -47,12 +49,12 @@ class InsertRegisterAction : VimActionHandler.SingleExecution() {
|
||||
val expression = readExpression(editor.ij)
|
||||
if (expression != null) {
|
||||
if (expression.isNotEmpty()) {
|
||||
val expressionValue = VimscriptParser.parseExpression(expression)?.evaluate(editor.ij, context.ij, Script(listOf()))
|
||||
val expressionValue = VimscriptParser.parseExpression(expression)?.evaluate((editor as IjVimEditor).editor, (context as IjExecutionContext).context, Script(listOf()))
|
||||
?: throw ExException("E15: Invalid expression: $expression")
|
||||
val textToStore = expressionValue.toInsertableString()
|
||||
VimPlugin.getRegister().storeTextSpecial('=', textToStore)
|
||||
}
|
||||
VimPlugin.getChange().insertRegister(editor.ij, context.ij, argument.character)
|
||||
VimPlugin.getChange().insertRegister(editor, context, argument.character)
|
||||
}
|
||||
} catch (e: ExException) {
|
||||
VimPlugin.indicateError()
|
||||
@@ -61,7 +63,7 @@ class InsertRegisterAction : VimActionHandler.SingleExecution() {
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
return argument != null && VimPlugin.getChange().insertRegister(editor.ij, context.ij, argument.character)
|
||||
return argument != null && VimPlugin.getChange().insertRegister(editor, context, argument.character)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,6 @@ import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.handler.VimActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.newapi.ij
|
||||
import java.util.*
|
||||
|
||||
class InsertSingleCommandAction : VimActionHandler.SingleExecution() {
|
||||
@@ -34,7 +33,7 @@ class InsertSingleCommandAction : VimActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_CLEAR_STROKES, CommandFlags.FLAG_EXPECT_MORE)
|
||||
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean {
|
||||
VimPlugin.getChange().processSingleCommand(editor.ij)
|
||||
VimPlugin.getChange().processSingleCommand(editor)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -28,6 +28,7 @@ import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.group.visual.VimSelection
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -39,13 +40,13 @@ class VisualBlockAppendAction : VisualOperatorActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MULTIKEY_UNDO, CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeForAllCarets(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
caretsAndSelections: Map<Caret, VimSelection>,
|
||||
caretsAndSelections: Map<VimCaret, VimSelection>,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
if (editor.isOneLineMode) return false
|
||||
if ((editor as IjVimEditor).editor.isOneLineMode) return false
|
||||
val range = caretsAndSelections.values.stream().findFirst().orElse(null) ?: return false
|
||||
return if (range.type == SelectionType.BLOCK_WISE) {
|
||||
VimPlugin.getChange().blockInsert(editor, context, range.toVimTextRange(false), true, operatorArguments)
|
||||
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.insert
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -28,6 +28,7 @@ import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.group.visual.VimSelection
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -39,13 +40,13 @@ class VisualBlockInsertAction : VisualOperatorActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MULTIKEY_UNDO, CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeForAllCarets(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
caretsAndSelections: Map<Caret, VimSelection>,
|
||||
caretsAndSelections: Map<VimCaret, VimSelection>,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
if (editor.isOneLineMode) return false
|
||||
if ((editor as IjVimEditor).editor.isOneLineMode) return false
|
||||
val vimSelection = caretsAndSelections.values.stream().findFirst().orElse(null) ?: return false
|
||||
return if (vimSelection.type == SelectionType.BLOCK_WISE) {
|
||||
VimPlugin.getChange().blockInsert(editor, context, vimSelection.toVimTextRange(false), false, operatorArguments)
|
||||
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.shift
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.DuplicableOperatorAction
|
||||
@@ -38,9 +38,9 @@ class AutoIndentMotionAction : ChangeEditorActionHandler.ForEachCaret(), Duplica
|
||||
override val duplicateWith: Char = '='
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
|
@@ -18,10 +18,10 @@
|
||||
|
||||
package com.maddyhome.idea.vim.action.change.shift
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -40,9 +40,9 @@ class ShiftLeftLinesAction : ChangeEditorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_SAVE_STROKE)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
@@ -60,9 +60,9 @@ class ShiftLeftMotionAction : ChangeEditorActionHandler.ForEachCaret(), Duplicab
|
||||
override val duplicateWith: Char = '<'
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
@@ -79,9 +79,9 @@ class ShiftLeftVisualAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
|
@@ -18,10 +18,10 @@
|
||||
|
||||
package com.maddyhome.idea.vim.action.change.shift
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -40,9 +40,9 @@ class ShiftRightLinesAction : ChangeEditorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_SAVE_STROKE)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
@@ -60,9 +60,9 @@ class ShiftRightMotionAction : ChangeEditorActionHandler.ForEachCaret(), Duplica
|
||||
override val duplicateWith: Char = '>'
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
@@ -79,9 +79,9 @@ class ShiftRightVisualAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
|
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.copy
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -27,6 +27,8 @@ import com.maddyhome.idea.vim.group.copy.PutData
|
||||
import com.maddyhome.idea.vim.group.copy.PutData.TextData
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.StringHelper
|
||||
import com.maddyhome.idea.vim.newapi.IjExecutionContext
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
|
||||
sealed class PutTextBaseAction(
|
||||
private val insertTextBeforeCaret: Boolean,
|
||||
@@ -36,8 +38,8 @@ sealed class PutTextBaseAction(
|
||||
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments
|
||||
): Boolean {
|
||||
@@ -48,7 +50,7 @@ sealed class PutTextBaseAction(
|
||||
lastRegister.transferableData
|
||||
) else null
|
||||
val putData = PutData(textData, null, operatorArguments.count1, insertTextBeforeCaret, indent, caretAfterInsertedText, -1)
|
||||
return VimPlugin.getPut().putText(editor, context, putData)
|
||||
return VimPlugin.getPut().putText((editor as IjVimEditor).editor, (context as IjExecutionContext).context, putData)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,10 +18,10 @@
|
||||
|
||||
package com.maddyhome.idea.vim.action.copy
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -29,6 +29,9 @@ import com.maddyhome.idea.vim.group.copy.PutData
|
||||
import com.maddyhome.idea.vim.group.visual.VimSelection
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.newapi.IjExecutionContext
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -45,20 +48,23 @@ sealed class PutVisualTextBaseAction(
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeForAllCarets(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
caretsAndSelections: Map<Caret, VimSelection>,
|
||||
caretsAndSelections: Map<VimCaret, VimSelection>,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
if (caretsAndSelections.isEmpty()) return false
|
||||
val textData = VimPlugin.getRegister().lastRegister?.let { PutData.TextData(it.text, it.type, it.transferableData) }
|
||||
VimPlugin.getRegister().resetRegister()
|
||||
|
||||
val selection = PutData.VisualSelection(caretsAndSelections, caretsAndSelections.values.first().type)
|
||||
val selection = PutData.VisualSelection(
|
||||
caretsAndSelections.map { (it.key as IjVimCaret).caret to it.value }.toMap(),
|
||||
caretsAndSelections.values.first().type
|
||||
)
|
||||
val putData = PutData(textData, selection, cmd.count, insertTextBeforeCaret, indent, caretAfterInsertedText)
|
||||
|
||||
return VimPlugin.getPut().putText(editor, context, putData, true)
|
||||
return VimPlugin.getPut().putText((editor as IjVimEditor).editor, (context as IjExecutionContext).context, putData, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.copy
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -28,6 +28,7 @@ import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.group.visual.VimSelection
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -39,10 +40,10 @@ class YankVisualAction : VisualOperatorActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeForAllCarets(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
caretsAndSelections: Map<Caret, VimSelection>,
|
||||
caretsAndSelections: Map<VimCaret, VimSelection>,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
val selections = caretsAndSelections.values
|
||||
@@ -56,6 +57,6 @@ class YankVisualAction : VisualOperatorActionHandler.SingleExecution() {
|
||||
val vimSelection = selections.firstOrNull() ?: return false
|
||||
val startsArray = starts.toIntArray()
|
||||
val endsArray = ends.toIntArray()
|
||||
return VimPlugin.getYank().yankRange(editor, TextRange(startsArray, endsArray), vimSelection.type, true)
|
||||
return VimPlugin.getYank().yankRange((editor as IjVimEditor).editor, TextRange(startsArray, endsArray), vimSelection.type, true)
|
||||
}
|
||||
}
|
||||
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.copy
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -29,6 +29,7 @@ import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.group.visual.VimSelection
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -40,10 +41,10 @@ class YankVisualLinesAction : VisualOperatorActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE, CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeForAllCarets(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
caretsAndSelections: Map<Caret, VimSelection>,
|
||||
caretsAndSelections: Map<VimCaret, VimSelection>,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
val selections = caretsAndSelections.values
|
||||
@@ -60,6 +61,6 @@ class YankVisualLinesAction : VisualOperatorActionHandler.SingleExecution() {
|
||||
|
||||
val selection =
|
||||
if (vimSelection.type == SelectionType.BLOCK_WISE) SelectionType.BLOCK_WISE else SelectionType.LINE_WISE
|
||||
return VimPlugin.getYank().yankRange(editor, TextRange(startsArray, endsArray), selection, true)
|
||||
return VimPlugin.getYank().yankRange((editor as IjVimEditor).editor, TextRange(startsArray, endsArray), selection, true)
|
||||
}
|
||||
}
|
||||
|
@@ -18,14 +18,12 @@
|
||||
|
||||
package com.maddyhome.idea.vim.action.motion.select
|
||||
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.handler.VimActionHandler
|
||||
import com.maddyhome.idea.vim.helper.getTopLevelEditor
|
||||
import com.maddyhome.idea.vim.newapi.ij
|
||||
|
||||
/**
|
||||
* @author Alex Plate
|
||||
@@ -36,7 +34,7 @@ class SelectEnterAction : VimActionHandler.SingleExecution() {
|
||||
override val type: Command.Type = Command.Type.INSERT
|
||||
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean {
|
||||
VimPlugin.getChange().processEnter(editor.ij.getTopLevelEditor(), context.ij)
|
||||
injector.changeGroup.processEnter(editor, context)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,8 @@ import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.group.MotionGroup
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.fileSize
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import kotlin.math.min
|
||||
|
||||
@@ -153,7 +155,7 @@ class Ranges {
|
||||
if (range.isMove) {
|
||||
MotionGroup.moveCaret(
|
||||
editor, editor.caretModel.primaryCaret,
|
||||
VimPlugin.getMotion().moveCaretToLineWithSameColumn(editor, endLine, editor.caretModel.primaryCaret)
|
||||
VimPlugin.getMotion().moveCaretToLineWithSameColumn(IjVimEditor(editor), endLine, IjVimCaret(editor.caretModel.primaryCaret))
|
||||
)
|
||||
}
|
||||
// Did that last range represent the start of the file?
|
||||
@@ -177,7 +179,7 @@ class Ranges {
|
||||
if (range.isMove) MotionGroup.moveCaret(
|
||||
editor,
|
||||
caret,
|
||||
VimPlugin.getMotion().moveCaretToLineWithSameColumn(editor, endLine, editor.caretModel.primaryCaret)
|
||||
VimPlugin.getMotion().moveCaretToLineWithSameColumn(IjVimEditor(editor), endLine, IjVimCaret(editor.caretModel.primaryCaret))
|
||||
)
|
||||
lastZero = endLine < 0
|
||||
++count
|
||||
|
@@ -22,7 +22,7 @@ import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.KeyHandler
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.action.change.VimRepeater
|
||||
import com.maddyhome.idea.vim.action.change.Extension
|
||||
import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.common.MappingMode
|
||||
import com.maddyhome.idea.vim.helper.CommandLineHelper
|
||||
@@ -104,8 +104,8 @@ object VimExtensionFacade {
|
||||
@JvmStatic
|
||||
fun inputKeyStroke(editor: Editor): KeyStroke {
|
||||
if (editor.vim.commandState.isDotRepeatInProgress) {
|
||||
val input = VimRepeater.Extension.consumeKeystroke()
|
||||
return input ?: error("Not enough keystrokes saved: ${VimRepeater.Extension.lastExtensionHandler}")
|
||||
val input = Extension.consumeKeystroke()
|
||||
return input ?: error("Not enough keystrokes saved: ${Extension.lastExtensionHandler}")
|
||||
}
|
||||
|
||||
val key: KeyStroke? = if (ApplicationManager.getApplication().isUnitTestMode) {
|
||||
@@ -119,7 +119,7 @@ object VimExtensionFacade {
|
||||
ref
|
||||
}
|
||||
val result = key ?: KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE.toChar())
|
||||
VimRepeater.Extension.addKeystroke(result)
|
||||
Extension.addKeystroke(result)
|
||||
return result
|
||||
}
|
||||
|
||||
|
@@ -39,8 +39,10 @@ import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.StringHelper
|
||||
import com.maddyhome.idea.vim.helper.mode
|
||||
import com.maddyhome.idea.vim.key.OperatorFunction
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import com.maddyhome.idea.vim.vimscript.model.options.helpers.ClipboardOptionHelper
|
||||
import com.maddyhome.idea.vim.options.helpers.ClipboardOptionHelper
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import java.awt.event.KeyEvent
|
||||
import javax.swing.KeyStroke
|
||||
@@ -186,8 +188,8 @@ class VimSurroundExtension : VimExtension {
|
||||
val change = VimPlugin.getChange()
|
||||
val leftSurround = pair.first
|
||||
val primaryCaret = editor.caretModel.primaryCaret
|
||||
change.insertText(editor, primaryCaret, range.startOffset, leftSurround)
|
||||
change.insertText(editor, primaryCaret, range.endOffset + leftSurround.length, pair.second)
|
||||
change.insertText(IjVimEditor(editor), IjVimCaret(primaryCaret), range.startOffset, leftSurround)
|
||||
change.insertText(IjVimEditor(editor), IjVimCaret(primaryCaret), range.endOffset + leftSurround.length, pair.second)
|
||||
// Jump back to start
|
||||
executeNormalWithoutMapping(StringHelper.parseKeys("`["), editor)
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -74,6 +74,13 @@ import static java.lang.Math.min;
|
||||
*/
|
||||
public class MotionGroup extends VimMotionGroupBase {
|
||||
|
||||
public @Nullable TextRange getMotionRange(@NotNull VimEditor editor,
|
||||
@NotNull VimCaret caret,
|
||||
ExecutionContext context,
|
||||
@NotNull Argument argument,
|
||||
@NotNull OperatorArguments operatorArguments) {
|
||||
return getMotionRange(((IjVimEditor) editor).getEditor(), ((IjVimCaret) caret).getCaret(), ((IjExecutionContext) context).getContext(), argument, operatorArguments);
|
||||
}
|
||||
/**
|
||||
* This helper method calculates the complete range a motion will move over taking into account whether
|
||||
* the motion is FLAG_MOT_LINEWISE or FLAG_MOT_CHARACTERWISE (FLAG_MOT_INCLUSIVE or FLAG_MOT_EXCLUSIVE).
|
||||
@@ -363,6 +370,10 @@ public class MotionGroup extends VimMotionGroupBase {
|
||||
return normalizeSideScrollOffset(editor, sideScrollOffset);
|
||||
}
|
||||
|
||||
public void moveCaret(@NotNull VimEditor editor, @NotNull VimCaret caret, int offset) {
|
||||
moveCaret(((IjVimEditor) editor).getEditor(), ((IjVimCaret) caret).getCaret(), offset);
|
||||
}
|
||||
|
||||
public static void moveCaret(@NotNull Editor editor, @NotNull Caret caret, int offset) {
|
||||
if (offset < 0 || offset > editor.getDocument().getTextLength() || !caret.isValid()) return;
|
||||
|
||||
@@ -883,11 +894,11 @@ public class MotionGroup extends VimMotionGroupBase {
|
||||
return getLeadingCharacterOffset(((IjVimEditor)editor).getEditor(), line);
|
||||
}
|
||||
|
||||
public int moveCaretToLineEnd(@NotNull Editor editor, @NotNull Caret caret) {
|
||||
final VisualPosition visualPosition = caret.getVisualPosition();
|
||||
final int lastVisualLineColumn = EditorUtil.getLastVisualLineColumnNumber(editor, visualPosition.line);
|
||||
public int moveCaretToLineEnd(@NotNull VimEditor editor, @NotNull VimCaret caret) {
|
||||
final VisualPosition visualPosition = ((IjVimCaret) caret).getCaret().getVisualPosition();
|
||||
final int lastVisualLineColumn = EditorUtil.getLastVisualLineColumnNumber(((IjVimEditor) editor).getEditor(), visualPosition.line);
|
||||
final VisualPosition visualEndOfLine = new VisualPosition(visualPosition.line, lastVisualLineColumn, true);
|
||||
return moveCaretToLineEnd(new IjVimEditor(editor), editor.visualToLogicalPosition(visualEndOfLine).line, true);
|
||||
return moveCaretToLineEnd(editor, ((IjVimEditor) editor).getEditor().visualToLogicalPosition(visualEndOfLine).line, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -995,23 +1006,23 @@ public class MotionGroup extends VimMotionGroupBase {
|
||||
return caretVisualLine == EditorHelper.getVisualLineCount(editor) - 2;
|
||||
}
|
||||
|
||||
public @Range(from = 0, to = Integer.MAX_VALUE) int moveCaretToLineWithSameColumn(@NotNull Editor editor,
|
||||
public @Range(from = 0, to = Integer.MAX_VALUE) int moveCaretToLineWithSameColumn(@NotNull VimEditor editor,
|
||||
int logicalLine,
|
||||
@NotNull Caret caret) {
|
||||
int col = UserDataManager.getVimLastColumn(caret);
|
||||
@NotNull VimCaret caret) {
|
||||
int col = UserDataManager.getVimLastColumn(((IjVimCaret) caret).getCaret());
|
||||
int line = logicalLine;
|
||||
if (logicalLine < 0) {
|
||||
line = 0;
|
||||
col = 0;
|
||||
}
|
||||
else if (logicalLine >= getLineCount(editor)) {
|
||||
line = normalizeLine(editor, getLineCount(editor) - 1);
|
||||
col = getLineLength(editor, line);
|
||||
else if (logicalLine >= editor.lineCount()) {
|
||||
line = normalizeLine(((IjVimEditor) editor).getEditor(), editor.lineCount() - 1);
|
||||
col = getLineLength(((IjVimEditor) editor).getEditor(), line);
|
||||
}
|
||||
|
||||
LogicalPosition newPos = new LogicalPosition(line, normalizeColumn(editor, line, col, false));
|
||||
LogicalPosition newPos = new LogicalPosition(line, normalizeColumn(((IjVimEditor) editor).getEditor(), line, col, false));
|
||||
|
||||
return editor.logicalPositionToOffset(newPos);
|
||||
return ((IjVimEditor) editor).getEditor().logicalPositionToOffset(newPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1022,8 +1033,7 @@ public class MotionGroup extends VimMotionGroupBase {
|
||||
return moveCaretToLineStartSkipLeading(editor, logicalLine);
|
||||
}
|
||||
else {
|
||||
return moveCaretToLineWithSameColumn(((IjVimEditor)editor).getEditor(), logicalLine,
|
||||
((IjVimCaret)caret).getCaret());
|
||||
return moveCaretToLineWithSameColumn(editor, logicalLine, caret);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -43,6 +43,7 @@ import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.ex.ExException;
|
||||
import com.maddyhome.idea.vim.ex.InvalidCommandException;
|
||||
import com.maddyhome.idea.vim.helper.UiHelper;
|
||||
import com.maddyhome.idea.vim.newapi.IjExecutionContext;
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor;
|
||||
import com.maddyhome.idea.vim.options.OptionConstants;
|
||||
import com.maddyhome.idea.vim.options.OptionScope;
|
||||
@@ -157,11 +158,12 @@ public class ProcessGroup implements VimProcessGroup {
|
||||
panel.deactivate(true, resetCaret);
|
||||
}
|
||||
|
||||
public void startFilterCommand(@NotNull Editor editor, DataContext context, @NotNull Command cmd) {
|
||||
String initText = getRange(editor, cmd) + "!";
|
||||
CommandState.getInstance(new IjVimEditor(editor)).pushModes(CommandState.Mode.CMD_LINE, CommandState.SubMode.NONE);
|
||||
@Override
|
||||
public void startFilterCommand(@NotNull VimEditor editor, ExecutionContext context, @NotNull Command cmd) {
|
||||
String initText = getRange(((IjVimEditor) editor).getEditor(), cmd) + "!";
|
||||
CommandState.getInstance(editor).pushModes(CommandState.Mode.CMD_LINE, CommandState.SubMode.NONE);
|
||||
ExEntryPanel panel = ExEntryPanel.getInstance();
|
||||
panel.activate(editor, context, ":", initText, 1);
|
||||
panel.activate(((IjVimEditor) editor).getEditor(), ((IjExecutionContext) context).getContext(), ":", initText, 1);
|
||||
}
|
||||
|
||||
private @NotNull String getRange(Editor editor, @NotNull Command cmd) {
|
||||
|
@@ -36,6 +36,7 @@ import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.api.VimCaret;
|
||||
import com.maddyhome.idea.vim.api.VimEditor;
|
||||
import com.maddyhome.idea.vim.api.VimInjectorKt;
|
||||
import com.maddyhome.idea.vim.api.VimSearchGroupBase;
|
||||
@@ -46,6 +47,7 @@ import com.maddyhome.idea.vim.ex.ExException;
|
||||
import com.maddyhome.idea.vim.ex.ranges.LineRange;
|
||||
import com.maddyhome.idea.vim.helper.*;
|
||||
import com.maddyhome.idea.vim.history.HistoryConstants;
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret;
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor;
|
||||
import com.maddyhome.idea.vim.options.OptionChangeListener;
|
||||
import com.maddyhome.idea.vim.options.OptionConstants;
|
||||
@@ -72,6 +74,7 @@ import java.text.NumberFormat;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.*;
|
||||
|
||||
import static com.maddyhome.idea.vim.api.VimInjectorKt.injector;
|
||||
import static com.maddyhome.idea.vim.helper.HelperKt.localEditors;
|
||||
import static com.maddyhome.idea.vim.helper.SearchHelperKtKt.shouldIgnoreCase;
|
||||
import static com.maddyhome.idea.vim.register.RegisterConstants.LAST_SEARCH_REGISTER;
|
||||
@@ -525,12 +528,12 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
||||
* @return True if the substitution succeeds, false on error. Will succeed even if nothing is modified
|
||||
*/
|
||||
@RWLockLabel.SelfSynchronized
|
||||
public boolean processSubstituteCommand(@NotNull Editor editor, @NotNull Caret caret, @NotNull LineRange range,
|
||||
public boolean processSubstituteCommand(@NotNull VimEditor editor, @NotNull VimCaret caret, @NotNull LineRange range,
|
||||
@NotNull @NonNls String excmd, @NonNls String exarg, @NotNull VimLContext parent) {
|
||||
// Explicitly exit visual mode here, so that visual mode marks don't change when we move the cursor to a match.
|
||||
List<ExException> exceptions = new ArrayList<>();
|
||||
if (CommandStateHelper.inVisualMode(editor)) {
|
||||
ModeHelper.exitVisualMode(editor);
|
||||
if (CommandStateHelper.inVisualMode(((IjVimEditor) editor).getEditor())) {
|
||||
ModeHelper.exitVisualMode(((IjVimEditor) editor).getEditor());
|
||||
}
|
||||
|
||||
CharPointer cmd = new CharPointer(new StringBuffer(exarg));
|
||||
@@ -620,7 +623,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
||||
}
|
||||
else {
|
||||
// :h :&& - "Note that :s and :& don't keep the flags"
|
||||
do_all = VimPlugin.getOptionService().isSet(new OptionScope.LOCAL(new IjVimEditor(editor)), OptionConstants.gdefaultName, OptionConstants.gdefaultName);
|
||||
do_all = VimPlugin.getOptionService().isSet(new OptionScope.LOCAL(editor), OptionConstants.gdefaultName, OptionConstants.gdefaultName);
|
||||
do_ask = false;
|
||||
do_error = true;
|
||||
do_ic = 0;
|
||||
@@ -677,7 +680,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
||||
return false;
|
||||
}
|
||||
line1 = line2;
|
||||
line2 = EditorHelper.normalizeLine(editor, line1 + i - 1);
|
||||
line2 = EditorHelper.normalizeLine(((IjVimEditor) editor).getEditor(), line1 + i - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -734,8 +737,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
||||
resetShowSearchHighlight();
|
||||
forceUpdateSearchHighlights();
|
||||
|
||||
int start = editor.getDocument().getLineStartOffset(line1);
|
||||
int end = editor.getDocument().getLineEndOffset(line2);
|
||||
int start = ((IjVimEditor) editor).getEditor().getDocument().getLineStartOffset(line1);
|
||||
int end = ((IjVimEditor) editor).getEditor().getDocument().getLineEndOffset(line2);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("search range=[" + start + "," + end + "]");
|
||||
@@ -747,14 +750,14 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
||||
int searchcol = 0;
|
||||
boolean firstMatch = true;
|
||||
boolean got_quit = false;
|
||||
int lcount = EditorHelper.getLineCount(editor);
|
||||
int lcount = EditorHelper.getLineCount(((IjVimEditor) editor).getEditor());
|
||||
Expression expression = null;
|
||||
for (int lnum = line1; lnum <= line2 && !got_quit; ) {
|
||||
CharacterPosition newpos = null;
|
||||
int nmatch = sp.vim_regexec_multi(regmatch, editor, lcount, lnum, searchcol);
|
||||
int nmatch = sp.vim_regexec_multi(regmatch, ((IjVimEditor) editor).getEditor(), lcount, lnum, searchcol);
|
||||
if (nmatch > 0) {
|
||||
if (firstMatch) {
|
||||
VimPlugin.getMark().saveJumpLocation(new IjVimEditor(editor));
|
||||
VimPlugin.getMark().saveJumpLocation(editor);
|
||||
firstMatch = false;
|
||||
}
|
||||
|
||||
@@ -774,15 +777,15 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
||||
int line = lnum + regmatch.startpos[0].lnum;
|
||||
CharacterPosition startpos = new CharacterPosition(lnum + regmatch.startpos[0].lnum, regmatch.startpos[0].col);
|
||||
CharacterPosition endpos = new CharacterPosition(lnum + regmatch.endpos[0].lnum, regmatch.endpos[0].col);
|
||||
int startoff = startpos.toOffset(editor);
|
||||
int endoff = endpos.toOffset(editor);
|
||||
int startoff = startpos.toOffset(((IjVimEditor) editor).getEditor());
|
||||
int endoff = endpos.toOffset(((IjVimEditor) editor).getEditor());
|
||||
|
||||
if (do_all || line != lastLine) {
|
||||
boolean doReplace = true;
|
||||
if (do_ask) {
|
||||
RangeHighlighter hl = SearchHighlightsHelper.addSubstitutionConfirmationHighlight(editor, startoff, endoff);
|
||||
final ReplaceConfirmationChoice choice = confirmChoice(editor, match, caret, startoff);
|
||||
editor.getMarkupModel().removeHighlighter(hl);
|
||||
RangeHighlighter hl = SearchHighlightsHelper.addSubstitutionConfirmationHighlight(((IjVimEditor) editor).getEditor(), startoff, endoff);
|
||||
final ReplaceConfirmationChoice choice = confirmChoice(((IjVimEditor) editor).getEditor(), match, ((IjVimCaret) caret).getCaret(), startoff);
|
||||
((IjVimEditor) editor).getEditor().getMarkupModel().removeHighlighter(hl);
|
||||
switch (choice) {
|
||||
case SUBSTITUTE_THIS:
|
||||
doReplace = true;
|
||||
@@ -805,12 +808,12 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
||||
}
|
||||
}
|
||||
if (doReplace) {
|
||||
SubmatchFunctionHandler.INSTANCE.setLatestMatch(editor.getDocument().getText(new com.intellij.openapi.util.TextRange(startoff, endoff)));
|
||||
MotionGroup.moveCaret(editor, caret, startoff);
|
||||
SubmatchFunctionHandler.INSTANCE.setLatestMatch(((IjVimEditor) editor).getEditor().getDocument().getText(new com.intellij.openapi.util.TextRange(startoff, endoff)));
|
||||
injector.getMotion().moveCaret(editor, caret, startoff);
|
||||
if (expression != null) {
|
||||
try {
|
||||
match = expression
|
||||
.evaluate(editor, EditorDataContext.init(editor, null), parent)
|
||||
.evaluate(((IjVimEditor) editor).getEditor(), EditorDataContext.init(((IjVimEditor) editor).getEditor(), null), parent)
|
||||
.toInsertableString();
|
||||
} catch (Exception e) {
|
||||
exceptions.add((ExException) e);
|
||||
@@ -819,11 +822,11 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
||||
}
|
||||
|
||||
String finalMatch = match;
|
||||
ApplicationManager.getApplication().runWriteAction(() -> editor.getDocument().replaceString(startoff, endoff,
|
||||
ApplicationManager.getApplication().runWriteAction(() -> ((IjVimEditor) editor).getEditor().getDocument().replaceString(startoff, endoff,
|
||||
finalMatch));
|
||||
lastMatch = startoff;
|
||||
int newend = startoff + match.length();
|
||||
newpos = CharacterPosition.Companion.fromOffset(editor, newend);
|
||||
newpos = CharacterPosition.Companion.fromOffset(((IjVimEditor) editor).getEditor(), newend);
|
||||
|
||||
lnum += newpos.line - endpos.line;
|
||||
line2 += newpos.line - endpos.line;
|
||||
@@ -855,8 +858,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
||||
|
||||
if (!got_quit) {
|
||||
if (lastMatch != -1) {
|
||||
MotionGroup.moveCaret(editor, caret,
|
||||
VimPlugin.getMotion().moveCaretToLineStartSkipLeading(new IjVimEditor(editor), editor.offsetToLogicalPosition(lastMatch).line));
|
||||
injector.getMotion().moveCaret(editor, caret,
|
||||
VimPlugin.getMotion().moveCaretToLineStartSkipLeading(editor, editor.offsetToLogicalPosition(lastMatch).getLine()));
|
||||
}
|
||||
else {
|
||||
VimPlugin.showMessage(MessageHelper.message(Msg.e_patnotf2, pattern));
|
||||
|
@@ -48,12 +48,15 @@ import com.maddyhome.idea.vim.helper.TestClipboardModel
|
||||
import com.maddyhome.idea.vim.helper.fileSize
|
||||
import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset
|
||||
import com.maddyhome.idea.vim.mark.VimMarkConstants.MARK_CHANGE_POS
|
||||
import com.maddyhome.idea.vim.newapi.IjExecutionContext
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import com.maddyhome.idea.vim.options.OptionConstants
|
||||
import com.maddyhome.idea.vim.options.OptionScope
|
||||
import com.maddyhome.idea.vim.options.helpers.ClipboardOptionHelper
|
||||
import com.maddyhome.idea.vim.put.VimPutBase
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString
|
||||
import com.maddyhome.idea.vim.vimscript.model.options.helpers.ClipboardOptionHelper
|
||||
import java.awt.datatransfer.DataFlavor
|
||||
import java.util.*
|
||||
import kotlin.math.abs
|
||||
@@ -161,7 +164,7 @@ class PutGroup : VimPutBase() {
|
||||
val range = selection.toVimTextRange(false).normalize()
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
VimPlugin.getChange().deleteRange(editor, caret, range, selection.type, false)
|
||||
VimPlugin.getChange().deleteRange(IjVimEditor(editor), IjVimCaret(caret), range, selection.type, false)
|
||||
}
|
||||
caret.moveToInlayAwareOffset(range.startOffset)
|
||||
}
|
||||
@@ -500,7 +503,7 @@ class PutGroup : VimPutBase() {
|
||||
val limit = currentLine + lineCount - EditorHelper.getLineCount(editor)
|
||||
for (i in 0 until limit) {
|
||||
MotionGroup.moveCaret(editor, caret, editor.fileSize)
|
||||
VimPlugin.getChange().insertText(editor, caret, "\n")
|
||||
VimPlugin.getChange().insertText(IjVimEditor(editor), IjVimCaret(caret), "\n")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -524,17 +527,17 @@ class PutGroup : VimPutBase() {
|
||||
val insertOffset = editor.logicalPositionToOffset(LogicalPosition(currentLine, currentColumn))
|
||||
MotionGroup.moveCaret(editor, caret, insertOffset)
|
||||
val insertedText = origSegment + segment.repeat(count - 1)
|
||||
VimPlugin.getChange().insertText(editor, caret, insertedText)
|
||||
VimPlugin.getChange().insertText(IjVimEditor(editor), IjVimCaret(caret), insertedText)
|
||||
endOffset += insertedText.length
|
||||
|
||||
if (mode == CommandState.SubMode.VISUAL_LINE) {
|
||||
MotionGroup.moveCaret(editor, caret, endOffset)
|
||||
VimPlugin.getChange().insertText(editor, caret, "\n")
|
||||
VimPlugin.getChange().insertText(IjVimEditor(editor), IjVimCaret(caret), "\n")
|
||||
++endOffset
|
||||
} else {
|
||||
if (pad.isNotEmpty()) {
|
||||
MotionGroup.moveCaret(editor, caret, insertOffset)
|
||||
VimPlugin.getChange().insertText(editor, caret, pad)
|
||||
VimPlugin.getChange().insertText(IjVimEditor(editor), IjVimCaret(caret), pad)
|
||||
endOffset += pad.length
|
||||
}
|
||||
}
|
||||
@@ -562,7 +565,7 @@ class PutGroup : VimPutBase() {
|
||||
): Int {
|
||||
MotionGroup.moveCaret(editor, caret, startOffset)
|
||||
val insertedText = text.repeat(count)
|
||||
VimPlugin.getChange().insertText(editor, caret, insertedText)
|
||||
VimPlugin.getChange().insertText(IjVimEditor(editor), IjVimCaret(caret), insertedText)
|
||||
|
||||
val endOffset = if (indent)
|
||||
doIndent(editor, caret, context, startOffset, startOffset + insertedText.length)
|
||||
@@ -615,7 +618,7 @@ class PutGroup : VimPutBase() {
|
||||
val startLineOffset = editor.document.getLineStartOffset(startLine)
|
||||
val endLineOffset = editor.document.getLineEndOffset(endLine)
|
||||
|
||||
VimPlugin.getChange().autoIndentRange(editor, caret, context, TextRange(startLineOffset, endLineOffset))
|
||||
VimPlugin.getChange().autoIndentRange(IjVimEditor(editor), IjVimCaret(caret), IjExecutionContext(context), TextRange(startLineOffset, endLineOffset))
|
||||
return EditorHelper.getLineEndOffset(editor, endLine, true)
|
||||
}
|
||||
|
||||
|
@@ -37,6 +37,7 @@ import com.maddyhome.idea.vim.helper.vimForEachCaret
|
||||
import com.maddyhome.idea.vim.helper.vimLastColumn
|
||||
import com.maddyhome.idea.vim.helper.vimLastVisualOperatorRange
|
||||
import com.maddyhome.idea.vim.helper.vimSelectionStart
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.ij
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
|
||||
@@ -64,7 +65,7 @@ class VisualMotionGroup : VimVisualMotionGroupBase() {
|
||||
|
||||
editor.ij.vimForEachCaret {
|
||||
val range = it.vimLastVisualOperatorRange ?: VisualChange.default(subMode)
|
||||
val end = VisualOperation.calculateRange(editor.ij, range, count, it)
|
||||
val end = VisualOperation.calculateRange(editor, range, count, IjVimCaret(it))
|
||||
val lastColumn =
|
||||
if (range.columns == VimMotionGroupBase.LAST_COLUMN) VimMotionGroupBase.LAST_COLUMN else editor.offsetToLogicalPosition(
|
||||
end
|
||||
|
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2022 The IdeaVim authors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.maddyhome.idea.vim.group.visual
|
||||
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.LogicalPosition
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.VimMotionGroupBase
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.inBlockSubMode
|
||||
import com.maddyhome.idea.vim.helper.sort
|
||||
import com.maddyhome.idea.vim.helper.subMode
|
||||
import com.maddyhome.idea.vim.helper.vimLastColumn
|
||||
import com.maddyhome.idea.vim.helper.vimSelectionStart
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import java.util.*
|
||||
import kotlin.math.min
|
||||
|
||||
data class VisualChange(val lines: Int, val columns: Int, val type: SelectionType) {
|
||||
companion object {
|
||||
fun default(subMode: CommandState.SubMode) =
|
||||
when (val type = SelectionType.fromSubMode(subMode)) {
|
||||
SelectionType.LINE_WISE, SelectionType.CHARACTER_WISE -> VisualChange(1, 1, type)
|
||||
SelectionType.BLOCK_WISE -> VisualChange(0, 1, type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object VisualOperation {
|
||||
/**
|
||||
* Get [VisualChange] of current visual operation
|
||||
*/
|
||||
fun getRange(editor: Editor, caret: Caret, cmdFlags: EnumSet<CommandFlags>): VisualChange {
|
||||
var (start, end) = caret.run {
|
||||
if (editor.inBlockSubMode) sort(vimSelectionStart, offset) else sort(selectionStart, selectionEnd)
|
||||
}
|
||||
val type = SelectionType.fromSubMode(editor.subMode)
|
||||
|
||||
start = EditorHelper.normalizeOffset(editor, start, false)
|
||||
end = EditorHelper.normalizeOffset(editor, end, false)
|
||||
val sp = editor.offsetToLogicalPosition(start)
|
||||
val ep = editor.offsetToLogicalPosition(end)
|
||||
var lines = ep.line - sp.line + 1
|
||||
if (type == SelectionType.LINE_WISE && ep.column == 0 && lines > 0) lines--
|
||||
|
||||
if (CommandFlags.FLAG_MOT_LINEWISE in cmdFlags) return VisualChange(lines, ep.column, SelectionType.LINE_WISE)
|
||||
|
||||
val chars = if (editor.caretModel.primaryCaret.vimLastColumn == VimMotionGroupBase.LAST_COLUMN) {
|
||||
VimMotionGroupBase.LAST_COLUMN
|
||||
} else when (type) {
|
||||
SelectionType.LINE_WISE -> ep.column
|
||||
SelectionType.CHARACTER_WISE -> if (lines > 1) ep.column - VimPlugin.getVisualMotion().selectionAdj else ep.column - sp.column
|
||||
SelectionType.BLOCK_WISE -> ep.column - sp.column + 1
|
||||
}
|
||||
|
||||
return VisualChange(lines, chars, type)
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate end offset of [VisualChange]
|
||||
*/
|
||||
fun calculateRange(editor: Editor, range: VisualChange, count: Int, caret: Caret): Int {
|
||||
var (lines, chars, type) = range
|
||||
if (type == SelectionType.LINE_WISE || type == SelectionType.BLOCK_WISE || lines > 1) {
|
||||
lines *= count
|
||||
}
|
||||
if (type == SelectionType.CHARACTER_WISE && lines == 1 || type == SelectionType.BLOCK_WISE) {
|
||||
chars *= count
|
||||
}
|
||||
val sp = caret.logicalPosition
|
||||
val linesDiff = (lines - 1).coerceAtLeast(0)
|
||||
val endLine = (sp.line + linesDiff).coerceAtMost(editor.document.lineCount - 1)
|
||||
|
||||
return when (type) {
|
||||
SelectionType.LINE_WISE -> VimPlugin.getMotion().moveCaretToLineWithSameColumn(editor, endLine, caret)
|
||||
SelectionType.CHARACTER_WISE -> when {
|
||||
lines > 1 -> VimPlugin.getMotion()
|
||||
.moveCaretToLineStart(editor.vim, endLine) + min(EditorHelper.getLineLength(editor, endLine), chars)
|
||||
else -> EditorHelper.normalizeOffset(editor, sp.line, caret.offset + chars - 1, true)
|
||||
}
|
||||
SelectionType.BLOCK_WISE -> {
|
||||
val endColumn = min(EditorHelper.getLineLength(editor, endLine), sp.column + chars - 1)
|
||||
editor.logicalPositionToOffset(LogicalPosition(endLine, endColumn))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,7 +21,7 @@ package com.maddyhome.idea.vim.helper
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.action.change.VimRepeater
|
||||
import com.maddyhome.idea.vim.action.change.Extension
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import com.maddyhome.idea.vim.ui.ModalEntry
|
||||
import com.maddyhome.idea.vim.ui.ex.ExEntryPanel
|
||||
@@ -33,8 +33,8 @@ class CommandLineHelper {
|
||||
|
||||
fun inputString(editor: Editor, prompt: String, finishOn: Char?): String? {
|
||||
if (editor.vim.commandState.isDotRepeatInProgress) {
|
||||
val input = VimRepeater.Extension.consumeString()
|
||||
return input ?: error("Not enough strings saved: ${VimRepeater.Extension.lastExtensionHandler}")
|
||||
val input = Extension.consumeString()
|
||||
return input ?: error("Not enough strings saved: ${Extension.lastExtensionHandler}")
|
||||
}
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode) {
|
||||
@@ -54,7 +54,7 @@ class CommandLineHelper {
|
||||
if (finishOn != null && key != null && key.keyChar == finishOn) {
|
||||
builder.append(key.keyChar)
|
||||
}
|
||||
VimRepeater.Extension.addString(builder.toString())
|
||||
Extension.addString(builder.toString())
|
||||
return builder.toString()
|
||||
} else {
|
||||
var text: String? = null
|
||||
@@ -85,7 +85,7 @@ class CommandLineHelper {
|
||||
}
|
||||
}
|
||||
if (text != null) {
|
||||
VimRepeater.Extension.addString(text!!)
|
||||
Extension.addString(text!!)
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package com.maddyhome.idea.vim.helper
|
||||
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.editor.ReadOnlyFragmentModificationException
|
||||
import com.intellij.openapi.editor.VisualPosition
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionManager
|
||||
import com.maddyhome.idea.vim.api.EngineEditorHelper
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
@@ -71,6 +73,10 @@ class IjEditorHelper : EngineEditorHelper {
|
||||
return EditorHelper.getLineStartOffset((editor as IjVimEditor).editor, line)
|
||||
}
|
||||
|
||||
override fun getLineStartForOffset(editor: VimEditor, line: Int): Int {
|
||||
return EditorHelper.getLineStartForOffset((editor as IjVimEditor).editor, line)
|
||||
}
|
||||
|
||||
override fun getLineEndForOffset(editor: VimEditor, offset: Int): Int {
|
||||
return EditorHelper.getLineEndForOffset((editor as IjVimEditor).editor, offset)
|
||||
}
|
||||
@@ -90,4 +96,10 @@ class IjEditorHelper : EngineEditorHelper {
|
||||
override fun getApproximateScreenWidth(editor: VimEditor): Int {
|
||||
return EditorHelper.getApproximateScreenWidth(editor.ij)
|
||||
}
|
||||
|
||||
override fun handleWithReadonlyFragmentModificationHandler(editor: VimEditor, exception: Exception) {
|
||||
return EditorActionManager.getInstance()
|
||||
.getReadonlyFragmentModificationHandler(editor.ij.document)
|
||||
.handle(exception as ReadOnlyFragmentModificationException?)
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.listener.SelectionVimListenerSuppressor
|
||||
import com.maddyhome.idea.vim.newapi.IjExecutionContext
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
@@ -110,5 +111,5 @@ fun VimEditor.exitSelectMode(adjustCaretPosition: Boolean) {
|
||||
}
|
||||
|
||||
fun Editor.exitInsertMode(context: DataContext, operatorArguments: OperatorArguments) {
|
||||
VimPlugin.getChange().processEscape(this, context, operatorArguments)
|
||||
VimPlugin.getChange().processEscape(IjVimEditor(this), IjExecutionContext(context), operatorArguments)
|
||||
}
|
||||
|
@@ -21,8 +21,8 @@ import com.intellij.openapi.application.invokeLater
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.editor.actionSystem.CaretSpecificDataContext
|
||||
import com.maddyhome.idea.vim.KeyHandler
|
||||
import com.maddyhome.idea.vim.action.change.VimRepeater.Extension.clean
|
||||
import com.maddyhome.idea.vim.action.change.VimRepeater.Extension.lastExtensionHandler
|
||||
import com.maddyhome.idea.vim.action.change.Extension.clean
|
||||
import com.maddyhome.idea.vim.action.change.Extension.lastExtensionHandler
|
||||
import com.maddyhome.idea.vim.action.change.VimRepeater.repeatHandler
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
|
@@ -74,12 +74,13 @@ import com.maddyhome.idea.vim.listener.MouseEventsDataHolder.skipEvents
|
||||
import com.maddyhome.idea.vim.listener.MouseEventsDataHolder.skipNDragEvents
|
||||
import com.maddyhome.idea.vim.listener.VimListenerManager.EditorListeners.add
|
||||
import com.maddyhome.idea.vim.listener.VimListenerManager.EditorListeners.remove
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import com.maddyhome.idea.vim.option.StrictMode
|
||||
import com.maddyhome.idea.vim.options.OptionConstants
|
||||
import com.maddyhome.idea.vim.options.helpers.KeywordOptionChangeListener
|
||||
import com.maddyhome.idea.vim.ui.ShowCmdOptionChangeListener
|
||||
import com.maddyhome.idea.vim.ui.ex.ExEntryPanel
|
||||
import com.maddyhome.idea.vim.vimscript.model.options.helpers.KeywordOptionChangeListener
|
||||
import java.awt.event.MouseAdapter
|
||||
import java.awt.event.MouseEvent
|
||||
import javax.swing.SwingUtilities
|
||||
@@ -164,7 +165,7 @@ object VimListenerManager {
|
||||
|
||||
VimPlugin.getEditor().editorCreated(editor)
|
||||
|
||||
VimPlugin.getChange().editorCreated(editor)
|
||||
VimPlugin.getChange().editorCreated(IjVimEditor(editor))
|
||||
}
|
||||
|
||||
fun remove(editor: Editor, isReleased: Boolean) {
|
||||
@@ -178,7 +179,7 @@ object VimListenerManager {
|
||||
|
||||
VimPlugin.getEditorIfCreated()?.editorDeinit(editor, isReleased)
|
||||
|
||||
VimPlugin.getChange().editorReleased(editor)
|
||||
VimPlugin.getChange().editorReleased(IjVimEditor(editor))
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -25,8 +25,8 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.psi.util.PsiUtilBase
|
||||
import com.intellij.util.text.CharArrayUtil
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.LineDeleteShift
|
||||
import com.maddyhome.idea.vim.api.MutableVimEditor
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.VimMotionGroupBase
|
||||
@@ -62,7 +62,7 @@ fun changeRange(
|
||||
var col = 0
|
||||
var lines = 0
|
||||
if (type === SelectionType.BLOCK_WISE) {
|
||||
lines = ChangeGroup.getLinesCountInVisualBlock(editor, range)
|
||||
lines = ChangeGroup.getLinesCountInVisualBlock(IjVimEditor(editor), range)
|
||||
col = editor.offsetToLogicalPosition(range.startOffset).column
|
||||
if (caret.vimLastColumn == VimMotionGroupBase.LAST_COLUMN) {
|
||||
col = VimMotionGroupBase.LAST_COLUMN
|
||||
@@ -111,33 +111,31 @@ fun changeRange(
|
||||
}
|
||||
|
||||
fun deleteRange(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
range: TextRange,
|
||||
type: SelectionType,
|
||||
): Boolean {
|
||||
val vimEditor = IjVimEditor(editor)
|
||||
val vimRange = toVimRange(range, type)
|
||||
|
||||
val vimCaret = IjVimCaret(caret)
|
||||
vimCaret.caret.vimLastColumn = vimCaret.caret.inlayAwareVisualColumn
|
||||
val deletedInfo = injector.vimMachine.delete(vimRange, vimEditor, vimCaret)
|
||||
(caret as IjVimCaret).caret.vimLastColumn = caret.caret.inlayAwareVisualColumn
|
||||
val deletedInfo = injector.vimMachine.delete(vimRange, editor, caret)
|
||||
if (deletedInfo != null) {
|
||||
when (deletedInfo) {
|
||||
is OperatedRange.Characters -> {
|
||||
val newOffset = EditorHelper.normalizeOffset(editor, deletedInfo.leftOffset.point, false)
|
||||
vimCaret.moveToOffset(newOffset)
|
||||
val newOffset = injector.engineEditorHelper.normalizeOffset(editor, deletedInfo.leftOffset.point, false)
|
||||
caret.moveToOffset(newOffset)
|
||||
}
|
||||
is OperatedRange.Block -> TODO()
|
||||
is OperatedRange.Lines -> {
|
||||
if (deletedInfo.shiftType != LineDeleteShift.NL_ON_START) {
|
||||
val line = deletedInfo.lineAbove.toPointer(vimEditor)
|
||||
val offset = vimCaret.offsetForLineWithStartOfLineOption(line)
|
||||
vimCaret.moveToOffset(offset)
|
||||
val line = deletedInfo.lineAbove.toPointer(editor)
|
||||
val offset = caret.offsetForLineWithStartOfLineOption(line)
|
||||
caret.moveToOffset(offset)
|
||||
} else {
|
||||
val logicalLine = EditorLine.Pointer.init((deletedInfo.lineAbove.line - 1).coerceAtLeast(0), vimEditor)
|
||||
val offset = vimCaret.offsetForLineWithStartOfLineOption(logicalLine)
|
||||
vimCaret.moveToOffset(offset)
|
||||
val logicalLine = EditorLine.Pointer.init((deletedInfo.lineAbove.line - 1).coerceAtLeast(0), editor)
|
||||
val offset = caret.offsetForLineWithStartOfLineOption(logicalLine)
|
||||
caret.moveToOffset(offset)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,51 +155,50 @@ fun deleteRange(
|
||||
* This is probably the kotlin issue, but still
|
||||
* - `*` character doesn't appear when `o` in javadoc section
|
||||
*/
|
||||
fun insertLineAround(editor: Editor, context: DataContext, shift: Int) {
|
||||
val vimEditor: MutableVimEditor = IjVimEditor(editor)
|
||||
val project = editor.project
|
||||
fun insertLineAround(editor: VimEditor, context: ExecutionContext, shift: Int) {
|
||||
val project = (editor as IjVimEditor).editor.project
|
||||
|
||||
VimPlugin.getChange().initInsert(editor, context, CommandState.Mode.INSERT)
|
||||
|
||||
if (!CommandState.getInstance(vimEditor).isDotRepeatInProgress) {
|
||||
for (vimCaret in vimEditor.carets()) {
|
||||
if (!CommandState.getInstance(editor).isDotRepeatInProgress) {
|
||||
for (vimCaret in editor.carets()) {
|
||||
val caret = (vimCaret as IjVimCaret).caret
|
||||
val line = vimCaret.getLine()
|
||||
|
||||
// Current line indent
|
||||
val lineStartOffset = vimEditor.getLineRange(line).first.point
|
||||
val text = editor.document.charsSequence
|
||||
val lineStartOffset = editor.getLineRange(line).first.point
|
||||
val text = editor.editor.document.charsSequence
|
||||
val lineStartWsEndOffset = CharArrayUtil.shiftForward(text, lineStartOffset, " \t")
|
||||
val indent = text.subSequence(lineStartOffset, lineStartWsEndOffset)
|
||||
|
||||
// Calculating next line with minding folders
|
||||
val lineEndOffset = if (shift == 1) {
|
||||
VimPlugin.getMotion().moveCaretToLineEnd(editor, caret)
|
||||
VimPlugin.getMotion().moveCaretToLineEnd(editor, IjVimCaret(caret))
|
||||
} else {
|
||||
VimPlugin.getMotion().moveCaretToLineStart(editor.vim, caret.vim)
|
||||
VimPlugin.getMotion().moveCaretToLineStart(editor, caret.vim)
|
||||
}
|
||||
val position = EditorLine.Offset.init(editor.offsetToLogicalPosition(lineEndOffset).line + shift, vimEditor)
|
||||
val position = EditorLine.Offset.init(editor.offsetToLogicalPosition(lineEndOffset).line + shift, editor)
|
||||
|
||||
val insertedLine = vimEditor.addLine(position) ?: continue
|
||||
val insertedLine = editor.addLine(position) ?: continue
|
||||
VimPlugin.getChange().saveStrokes("\n")
|
||||
|
||||
var lineStart = vimEditor.getLineRange(insertedLine).first
|
||||
var lineStart = editor.getLineRange(insertedLine).first
|
||||
val initialLineStart = lineStart
|
||||
|
||||
// Set up indent
|
||||
// Firstly set up primitive indent
|
||||
vimEditor.insertText(lineStart, indent)
|
||||
editor.insertText(lineStart, indent)
|
||||
lineStart = (lineStart.point + indent.length).offset
|
||||
|
||||
if (project != null) {
|
||||
// Secondly set up language smart indent
|
||||
val language = PsiUtilBase.getLanguageInEditor(caret, project)
|
||||
val newIndent = EnterHandler.adjustLineIndentNoCommit(language, editor.document, editor, lineStart.point)
|
||||
val newIndent = EnterHandler.adjustLineIndentNoCommit(language, editor.editor.document, editor.editor, lineStart.point)
|
||||
lineStart = if (newIndent >= 0) newIndent.offset else lineStart
|
||||
}
|
||||
VimPlugin.getChange()
|
||||
.saveStrokes(
|
||||
editor.document.getText(
|
||||
editor.editor.document.getText(
|
||||
com.intellij.openapi.util.TextRange(
|
||||
initialLineStart.point,
|
||||
lineStart.point
|
||||
@@ -213,16 +210,14 @@ fun insertLineAround(editor: Editor, context: DataContext, shift: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
MotionGroup.scrollCaretIntoView(editor)
|
||||
MotionGroup.scrollCaretIntoView(editor.editor)
|
||||
}
|
||||
|
||||
fun VimCaret.offsetForLineWithStartOfLineOption(logicalLine: EditorLine.Pointer): Int {
|
||||
val ijEditor = (this.editor as IjVimEditor).editor
|
||||
val caret = (this as IjVimCaret).caret
|
||||
return if (VimPlugin.getOptionService().isSet(OptionScope.LOCAL(editor), OptionConstants.startoflineName)) {
|
||||
offsetForLineStartSkipLeading(logicalLine.line)
|
||||
} else {
|
||||
VimPlugin.getMotion().moveCaretToLineWithSameColumn(ijEditor, logicalLine.line, caret)
|
||||
VimPlugin.getMotion().moveCaretToLineWithSameColumn(editor, logicalLine.line, this)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -22,16 +22,19 @@ import com.intellij.openapi.editor.Caret
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.VimLogicalPosition
|
||||
import com.maddyhome.idea.vim.api.VimVisualPosition
|
||||
import com.maddyhome.idea.vim.common.EditorLine
|
||||
import com.maddyhome.idea.vim.common.Offset
|
||||
import com.maddyhome.idea.vim.common.offset
|
||||
import com.maddyhome.idea.vim.group.MotionGroup
|
||||
import com.maddyhome.idea.vim.group.visual.VisualChange
|
||||
import com.maddyhome.idea.vim.group.visual.vimLeadSelectionOffset
|
||||
import com.maddyhome.idea.vim.group.visual.vimSetSelection
|
||||
import com.maddyhome.idea.vim.group.visual.vimSetSystemSelectionSilently
|
||||
import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset
|
||||
import com.maddyhome.idea.vim.helper.vimLastColumn
|
||||
import com.maddyhome.idea.vim.helper.vimLastVisualOperatorRange
|
||||
import com.maddyhome.idea.vim.helper.vimSelectionStart
|
||||
|
||||
class IjVimCaret(val caret: Caret) : VimCaret {
|
||||
@@ -55,7 +58,11 @@ class IjVimCaret(val caret: Caret) : VimCaret {
|
||||
}
|
||||
override val vimLeadSelectionOffset: Int
|
||||
get() = this.caret.vimLeadSelectionOffset
|
||||
|
||||
override var vimLastVisualOperatorRange: VisualChange?
|
||||
get() = this.caret.vimLastVisualOperatorRange
|
||||
set(value) {
|
||||
this.caret.vimLastVisualOperatorRange = value
|
||||
}
|
||||
override fun moveToOffset(offset: Int) {
|
||||
// TODO: 17.12.2021 Unpack internal actions
|
||||
MotionGroup.moveCaret(caret.editor, caret, offset)
|
||||
@@ -90,6 +97,11 @@ class IjVimCaret(val caret: Caret) : VimCaret {
|
||||
caret.vimSetSelection(start, end, moveCaretToSelectionEnd)
|
||||
}
|
||||
|
||||
override fun getLogicalPosition(): VimLogicalPosition {
|
||||
val logicalPosition = caret.logicalPosition
|
||||
return VimLogicalPosition(logicalPosition.line, logicalPosition.column, logicalPosition.leansForward)
|
||||
}
|
||||
|
||||
override fun getVisualPosition(): VimVisualPosition {
|
||||
val visualPosition = caret.visualPosition
|
||||
return VimVisualPosition(visualPosition.line, visualPosition.column, visualPosition.leansRight)
|
||||
|
@@ -33,6 +33,7 @@ import com.maddyhome.idea.vim.api.VimCaretListener
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.VimLogicalPosition
|
||||
import com.maddyhome.idea.vim.api.VimVisualPosition
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.common.EditorLine
|
||||
import com.maddyhome.idea.vim.common.Offset
|
||||
@@ -49,6 +50,8 @@ import com.maddyhome.idea.vim.helper.inBlockSubMode
|
||||
import com.maddyhome.idea.vim.helper.isTemplateActive
|
||||
import com.maddyhome.idea.vim.helper.updateCaretsVisualAttributes
|
||||
import com.maddyhome.idea.vim.helper.updateCaretsVisualPosition
|
||||
import com.maddyhome.idea.vim.helper.vimChangeActionSwitchMode
|
||||
import com.maddyhome.idea.vim.helper.vimKeepingVisualOperatorAction
|
||||
import com.maddyhome.idea.vim.helper.vimLastSelectionType
|
||||
|
||||
class IjVimEditor(editor: Editor) : MutableLinearEditor() {
|
||||
@@ -60,6 +63,16 @@ class IjVimEditor(editor: Editor) : MutableLinearEditor() {
|
||||
val originalEditor = editor
|
||||
|
||||
override val lfMakesNewLine: Boolean = true
|
||||
override var vimChangeActionSwitchMode: CommandState.Mode?
|
||||
get() = editor.vimChangeActionSwitchMode
|
||||
set(value) {
|
||||
editor.vimChangeActionSwitchMode = value
|
||||
}
|
||||
override var vimKeepingVisualOperatorAction: Boolean
|
||||
get() = editor.vimKeepingVisualOperatorAction
|
||||
set(value) {
|
||||
editor.vimKeepingVisualOperatorAction = value
|
||||
}
|
||||
|
||||
override fun fileSize(): Long = editor.fileSize.toLong()
|
||||
|
||||
@@ -134,13 +147,25 @@ class IjVimEditor(editor: Editor) : MutableLinearEditor() {
|
||||
|
||||
@Suppress("ideavimRunForEachCaret")
|
||||
override fun forEachCaret(action: (VimCaret) -> Unit) {
|
||||
forEachCaret(action, false)
|
||||
}
|
||||
|
||||
override fun forEachCaret(action: (VimCaret) -> Unit, reverse: Boolean) {
|
||||
if (editor.inBlockSubMode) {
|
||||
action(IjVimCaret(editor.caretModel.primaryCaret))
|
||||
} else {
|
||||
editor.caretModel.runForEachCaret { action(IjVimCaret(it)) }
|
||||
editor.caretModel.runForEachCaret({ action(IjVimCaret(it)) }, reverse)
|
||||
}
|
||||
}
|
||||
|
||||
override fun forEachNativeCaret(action: (VimCaret) -> Unit) {
|
||||
forEachNativeCaret(action, false)
|
||||
}
|
||||
|
||||
override fun forEachNativeCaret(action: (VimCaret) -> Unit, reverse: Boolean) {
|
||||
editor.caretModel.runForEachCaret({ action(IjVimCaret(it)) }, reverse)
|
||||
}
|
||||
|
||||
override fun primaryCaret(): VimCaret {
|
||||
return IjVimCaret(editor.caretModel.primaryCaret)
|
||||
}
|
||||
@@ -217,6 +242,10 @@ class IjVimEditor(editor: Editor) : MutableLinearEditor() {
|
||||
return EditorHelper.getLineLength(editor, line)
|
||||
}
|
||||
|
||||
override fun removeCaret(caret: VimCaret) {
|
||||
editor.caretModel.removeCaret((caret as IjVimCaret).caret)
|
||||
}
|
||||
|
||||
override fun removeSecondaryCarets() {
|
||||
editor.caretModel.removeSecondaryCarets()
|
||||
}
|
||||
@@ -276,6 +305,16 @@ class IjVimEditor(editor: Editor) : MutableLinearEditor() {
|
||||
this.editor.exitVisualMode()
|
||||
}
|
||||
|
||||
override fun startGuardedBlockChecking() {
|
||||
val doc = editor.document
|
||||
doc.startGuardedBlockChecking()
|
||||
}
|
||||
|
||||
override fun stopGuardedBlockChecking() {
|
||||
val doc = editor.document
|
||||
doc.stopGuardedBlockChecking()
|
||||
}
|
||||
|
||||
override var vimLastSelectionType: SelectionType?
|
||||
get() = editor.vimLastSelectionType
|
||||
set(value) {
|
||||
|
@@ -26,7 +26,7 @@ import com.maddyhome.idea.vim.vimscript.model.options.helpers.GuiCursorType
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
/**
|
||||
* @deprecated use {@link com.maddyhome.idea.vim.vimscript.model.options.helpers.GuiCursorOptionHelper} instead
|
||||
* @deprecated use {@link com.maddyhome.idea.vim.options.helpers.GuiCursorOptionHelper} instead
|
||||
*/
|
||||
@Deprecated("options are now replaced by helper classes")
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "1.11")
|
||||
|
@@ -19,9 +19,10 @@
|
||||
package com.maddyhome.idea.vim.option;
|
||||
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.options.OptionScope;
|
||||
import com.maddyhome.idea.vim.options.helpers.KeywordOptionHelper;
|
||||
import com.maddyhome.idea.vim.vimscript.model.commands.SetCommand;
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString;
|
||||
import com.maddyhome.idea.vim.options.OptionScope;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -37,7 +38,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated use {@link com.maddyhome.idea.vim.vimscript.model.options.helpers.KeywordOptionHelper} instead
|
||||
* @deprecated use {@link KeywordOptionHelper} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "1.11")
|
||||
|
@@ -24,6 +24,8 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.ex.ranges.Ranges
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
|
||||
|
||||
/**
|
||||
@@ -45,7 +47,7 @@ data class DeleteLinesCommand(val ranges: Ranges, var argument: String) : Comman
|
||||
|
||||
val textRange = getTextRange(editor, caret, true)
|
||||
return if (VimPlugin.getChange()
|
||||
.deleteRange(editor, caret, textRange, SelectionType.LINE_WISE, false)
|
||||
.deleteRange(IjVimEditor(editor), IjVimCaret(caret), textRange, SelectionType.LINE_WISE, false)
|
||||
) ExecutionResult.Success
|
||||
else ExecutionResult.Error
|
||||
}
|
||||
|
@@ -24,6 +24,8 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.ex.ranges.Ranges
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
|
||||
|
||||
/**
|
||||
@@ -39,7 +41,7 @@ data class JoinLinesCommand(val ranges: Ranges, val argument: String) : Command.
|
||||
val textRange = getTextRange(editor, caret, true)
|
||||
|
||||
return if (VimPlugin.getChange().deleteJoinRange(
|
||||
editor, caret,
|
||||
IjVimEditor(editor), IjVimCaret(caret),
|
||||
TextRange(
|
||||
textRange.startOffset,
|
||||
textRange.endOffset - 1
|
||||
|
@@ -25,6 +25,8 @@ import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.ex.ExException
|
||||
import com.maddyhome.idea.vim.ex.ranges.Ranges
|
||||
import com.maddyhome.idea.vim.group.MotionGroup
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.vimscript.Executor
|
||||
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
|
||||
|
||||
@@ -46,7 +48,7 @@ data class RepeatCommand(val ranges: Ranges, val argument: String) : Command.For
|
||||
MotionGroup.moveCaret(
|
||||
editor,
|
||||
caret,
|
||||
VimPlugin.getMotion().moveCaretToLineWithSameColumn(editor, line, editor.caretModel.primaryCaret)
|
||||
VimPlugin.getMotion().moveCaretToLineWithSameColumn(IjVimEditor(editor), line, IjVimCaret(editor.caretModel.primaryCaret))
|
||||
)
|
||||
|
||||
if (arg == ':') {
|
||||
|
@@ -24,6 +24,9 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.ex.ranges.Ranges
|
||||
import com.maddyhome.idea.vim.newapi.IjExecutionContext
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
|
||||
|
||||
/**
|
||||
@@ -36,7 +39,7 @@ data class ShiftLeftCommand(val ranges: Ranges, val argument: String, val length
|
||||
val range = getTextRange(editor, caret, true)
|
||||
val endOffsets = range.endOffsets.map { it - 1 }.toIntArray()
|
||||
VimPlugin.getChange().indentRange(
|
||||
editor, caret, context,
|
||||
IjVimEditor(editor), IjVimCaret(caret), IjExecutionContext(context),
|
||||
TextRange(range.startOffsets, endOffsets),
|
||||
length, -1
|
||||
)
|
||||
|
@@ -24,6 +24,9 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.ex.ranges.Ranges
|
||||
import com.maddyhome.idea.vim.newapi.IjExecutionContext
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
|
||||
|
||||
/**
|
||||
@@ -36,7 +39,7 @@ data class ShiftRightCommand(val ranges: Ranges, val argument: String, val lengt
|
||||
val range = getTextRange(editor, caret, true)
|
||||
val endOffsets = range.endOffsets.map { it - 1 }.toIntArray()
|
||||
VimPlugin.getChange().indentRange(
|
||||
editor, caret, context,
|
||||
IjVimEditor(editor), IjVimCaret(caret), IjExecutionContext(context),
|
||||
TextRange(range.startOffsets, endOffsets),
|
||||
length, 1
|
||||
)
|
||||
|
@@ -28,6 +28,7 @@ import com.maddyhome.idea.vim.ex.ranges.LineRange
|
||||
import com.maddyhome.idea.vim.ex.ranges.Ranges
|
||||
import com.maddyhome.idea.vim.helper.inBlockSubMode
|
||||
import com.maddyhome.idea.vim.helper.moveToInlayAwareOffset
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.newapi.vim
|
||||
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
|
||||
import java.util.*
|
||||
@@ -52,7 +53,7 @@ data class SortCommand(val ranges: Ranges, val argument: String) : Command.Singl
|
||||
if (editor.inBlockSubMode) {
|
||||
val primaryCaret = editor.caretModel.primaryCaret
|
||||
val range = getSortLineRange(editor, primaryCaret)
|
||||
val worked = VimPlugin.getChange().sortRange(editor, range, lineComparator)
|
||||
val worked = VimPlugin.getChange().sortRange(IjVimEditor(editor), range, lineComparator)
|
||||
primaryCaret.moveToInlayAwareOffset(
|
||||
VimPlugin.getMotion().moveCaretToLineStartSkipLeading(editor.vim, range.startLine)
|
||||
)
|
||||
@@ -62,7 +63,7 @@ data class SortCommand(val ranges: Ranges, val argument: String) : Command.Singl
|
||||
var worked = true
|
||||
for (caret in editor.caretModel.allCarets) {
|
||||
val range = getSortLineRange(editor, caret)
|
||||
if (!VimPlugin.getChange().sortRange(editor, range, lineComparator)) {
|
||||
if (!VimPlugin.getChange().sortRange(IjVimEditor(editor), range, lineComparator)) {
|
||||
worked = false
|
||||
}
|
||||
caret.moveToInlayAwareOffset(VimPlugin.getMotion().moveCaretToLineStartSkipLeading(editor.vim, range.startLine))
|
||||
|
@@ -22,6 +22,8 @@ import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.ex.ranges.Ranges
|
||||
import com.maddyhome.idea.vim.newapi.IjVimCaret
|
||||
import com.maddyhome.idea.vim.newapi.IjVimEditor
|
||||
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
|
||||
|
||||
/**
|
||||
@@ -33,7 +35,7 @@ data class SubstituteCommand(val ranges: Ranges, val argument: String, val comma
|
||||
var result = true
|
||||
for (caret in editor.caretModel.allCarets) {
|
||||
val lineRange = getLineRange(editor, caret)
|
||||
if (!VimPlugin.getSearch().processSubstituteCommand(editor, caret, lineRange, command, argument, this.vimContext)) {
|
||||
if (!VimPlugin.getSearch().processSubstituteCommand(IjVimEditor(editor), IjVimCaret(caret), lineRange, command, argument, this.vimContext)) {
|
||||
result = false
|
||||
}
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@ import com.maddyhome.idea.vim.options.OptionChangeListener
|
||||
import com.maddyhome.idea.vim.options.OptionConstants
|
||||
import com.maddyhome.idea.vim.options.OptionScope
|
||||
import com.maddyhome.idea.vim.options.OptionService
|
||||
import com.maddyhome.idea.vim.options.helpers.KeywordOptionHelper
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimInt
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString
|
||||
@@ -41,7 +42,6 @@ import com.maddyhome.idea.vim.vimscript.model.options.Option
|
||||
import com.maddyhome.idea.vim.vimscript.model.options.StringOption
|
||||
import com.maddyhome.idea.vim.vimscript.model.options.ToggleOption
|
||||
import com.maddyhome.idea.vim.vimscript.model.options.helpers.GuiCursorOptionHelper
|
||||
import com.maddyhome.idea.vim.vimscript.model.options.helpers.KeywordOptionHelper
|
||||
|
||||
internal class OptionServiceImpl : OptionService {
|
||||
|
||||
|
@@ -20,11 +20,11 @@ package org.jetbrains.plugins.ideavim.option;
|
||||
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.helper.CharacterHelper;
|
||||
import com.maddyhome.idea.vim.vimscript.Executor;
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString;
|
||||
import com.maddyhome.idea.vim.vimscript.model.options.helpers.KeywordOptionHelper;
|
||||
import com.maddyhome.idea.vim.options.OptionConstants;
|
||||
import com.maddyhome.idea.vim.options.OptionScope;
|
||||
import com.maddyhome.idea.vim.options.helpers.KeywordOptionHelper;
|
||||
import com.maddyhome.idea.vim.vimscript.Executor;
|
||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString;
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@@ -11,6 +11,9 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
|
||||
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
||||
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
|
||||
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.10'
|
||||
|
@@ -0,0 +1,18 @@
|
||||
package com.maddyhome.idea.vim.action.change
|
||||
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
|
||||
object VimRepeater {
|
||||
var repeatHandler = false
|
||||
|
||||
var lastChangeCommand: Command? = null
|
||||
private set
|
||||
var lastChangeRegister = injector.registerGroup.defaultRegister
|
||||
private set
|
||||
|
||||
fun saveLastChange(command: Command) {
|
||||
lastChangeCommand = command
|
||||
lastChangeRegister = injector.registerGroup.currentRegister
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -38,14 +38,14 @@ class AutoIndentLinesVisualAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE, CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
VimPlugin.getChange().autoIndentRange(editor, caret, context, range.toVimTextRange(true))
|
||||
injector.changeGroup.autoIndentRange(editor, caret, context, range.toVimTextRange(true))
|
||||
return true
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.DuplicableOperatorAction
|
||||
@@ -36,14 +36,14 @@ class ChangeCaseLowerMotionAction : ChangeEditorActionHandler.ForEachCaret(), Du
|
||||
override val duplicateWith: Char = 'u'
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return argument != null &&
|
||||
VimPlugin.getChange()
|
||||
injector.changeGroup
|
||||
.changeCaseMotion(
|
||||
editor,
|
||||
caret,
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -28,7 +28,6 @@ import com.maddyhome.idea.vim.group.visual.VimSelection
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.CharacterHelper
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.helper.getTopLevelEditor
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -40,15 +39,14 @@ class ChangeCaseLowerVisualAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
val topLevelEditor = editor.getTopLevelEditor()
|
||||
return VimPlugin.getChange()
|
||||
.changeCaseRange(topLevelEditor, caret, range.toVimTextRange(false), CharacterHelper.CASE_LOWER)
|
||||
return injector.changeGroup
|
||||
.changeCaseRange(editor, caret, range.toVimTextRange(false), CharacterHelper.CASE_LOWER)
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -30,12 +30,12 @@ class ChangeCaseToggleCharacterAction : ChangeEditorActionHandler.ForEachCaret()
|
||||
override val type: Command.Type = Command.Type.CHANGE
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return VimPlugin.getChange().changeCaseToggleCharacter(editor, caret, operatorArguments.count1)
|
||||
return injector.changeGroup.changeCaseToggleCharacter(editor, caret, operatorArguments.count1)
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.DuplicableOperatorAction
|
||||
@@ -36,14 +36,14 @@ class ChangeCaseToggleMotionAction : ChangeEditorActionHandler.ForEachCaret(), D
|
||||
override val duplicateWith: Char = '~'
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return argument != null &&
|
||||
VimPlugin.getChange()
|
||||
injector.changeGroup
|
||||
.changeCaseMotion(
|
||||
editor,
|
||||
caret,
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -39,14 +39,14 @@ class ChangeCaseToggleVisualAction : VisualOperatorActionHandler.ForEachCaret()
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return VimPlugin.getChange()
|
||||
return injector.changeGroup
|
||||
.changeCaseRange(editor, caret, range.toVimTextRange(false), CharacterHelper.CASE_TOGGLE)
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.DuplicableOperatorAction
|
||||
@@ -36,14 +36,14 @@ class ChangeCaseUpperMotionAction : ChangeEditorActionHandler.ForEachCaret(), Du
|
||||
override val duplicateWith: Char = 'U'
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return argument != null &&
|
||||
VimPlugin.getChange()
|
||||
injector.changeGroup
|
||||
.changeCaseMotion(
|
||||
editor,
|
||||
caret,
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -39,14 +39,14 @@ class ChangeCaseUpperVisualAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return VimPlugin.getChange()
|
||||
return injector.changeGroup
|
||||
.changeCaseRange(editor, caret, range.toVimTextRange(false), CharacterHelper.CASE_UPPER)
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -37,12 +37,12 @@ class ChangeCharacterAction : ChangeEditorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_ALLOW_DIGRAPH)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return argument != null && VimPlugin.getChange().changeCharacter(editor, caret, operatorArguments.count1, argument.character)
|
||||
return argument != null && injector.changeGroup.changeCharacter(editor, caret, operatorArguments.count1, argument.character)
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -37,12 +37,12 @@ class ChangeCharactersAction : ChangeEditorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_NO_REPEAT_INSERT, FLAG_MULTIKEY_UNDO)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return VimPlugin.getChange().changeCharacters(editor, caret, operatorArguments.count1)
|
||||
return injector.changeGroup.changeCharacters(editor, caret, operatorArguments.count1)
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -37,12 +37,12 @@ class ChangeEndOfLineAction : ChangeEditorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_NO_REPEAT_INSERT, FLAG_MULTIKEY_UNDO)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return VimPlugin.getChange().changeEndOfLine(editor, caret, operatorArguments.count1)
|
||||
return injector.changeGroup.changeEndOfLine(editor, caret, operatorArguments.count1)
|
||||
}
|
||||
}
|
@@ -17,11 +17,11 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.action.motion.updown.MotionDownLess1FirstNonSpaceAction
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -38,16 +38,16 @@ class ChangeLineAction : ChangeEditorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_NO_REPEAT_INSERT, FLAG_MULTIKEY_UNDO)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
// `S` command is a synonym of `cc`
|
||||
val motion = MotionDownLess1FirstNonSpaceAction()
|
||||
val command = Command(1, motion, motion.type, motion.flags)
|
||||
return VimPlugin.getChange().changeMotion(
|
||||
return injector.changeGroup.changeMotion(
|
||||
editor,
|
||||
caret,
|
||||
context,
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.DuplicableOperatorAction
|
||||
@@ -35,13 +35,13 @@ class ChangeMotionAction : ChangeEditorActionHandler.ForEachCaret(), DuplicableO
|
||||
override val duplicateWith: Char = 'c'
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return argument != null && VimPlugin.getChange().changeMotion(
|
||||
return argument != null && injector.changeGroup.changeMotion(
|
||||
editor,
|
||||
caret,
|
||||
context,
|
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -34,12 +34,12 @@ class ChangeReplaceAction : ChangeEditorActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MULTIKEY_UNDO)
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
VimPlugin.getChange().changeReplace(editor, context)
|
||||
injector.changeGroup.changeReplace(editor, context)
|
||||
return true
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -38,14 +38,14 @@ class ChangeVisualAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MULTIKEY_UNDO, CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return VimPlugin.getChange().changeRange(
|
||||
return injector.changeGroup.changeRange(
|
||||
editor,
|
||||
caret,
|
||||
range.toVimTextRange(false),
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
@@ -41,15 +41,15 @@ class ChangeVisualCharacterAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_ALLOW_DIGRAPH, CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
val argument = cmd.argument
|
||||
return argument != null &&
|
||||
VimPlugin.getChange().changeCharacterRange(editor, range.toVimTextRange(false), argument.character)
|
||||
injector.changeGroup.changeCharacterRange(editor, range.toVimTextRange(false), argument.character)
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.CommandFlags.FLAG_EXIT_VISUAL
|
||||
@@ -31,9 +31,7 @@ import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.group.visual.VimSelection
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.helper.fileSize
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -45,21 +43,21 @@ class ChangeVisualLinesAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_MOT_LINEWISE, FLAG_MULTIKEY_UNDO, FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
val textRange = range.toVimTextRange(true)
|
||||
val lineEndForOffset = EditorHelper.getLineEndForOffset(editor, textRange.endOffset)
|
||||
val endsWithNewLine = if (lineEndForOffset == editor.fileSize) 0 else 1
|
||||
val lineEndForOffset = injector.engineEditorHelper.getLineEndForOffset(editor, textRange.endOffset)
|
||||
val endsWithNewLine = if (lineEndForOffset.toLong() == editor.fileSize()) 0 else 1
|
||||
val lineRange = TextRange(
|
||||
EditorHelper.getLineStartForOffset(editor, textRange.startOffset),
|
||||
injector.engineEditorHelper.getLineStartForOffset(editor, textRange.startOffset),
|
||||
lineEndForOffset + endsWithNewLine
|
||||
)
|
||||
return VimPlugin.getChange().changeRange(
|
||||
return injector.changeGroup.changeRange(
|
||||
editor,
|
||||
caret,
|
||||
lineRange,
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.CommandFlags.FLAG_EXIT_VISUAL
|
||||
@@ -31,9 +31,7 @@ import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.group.visual.VimSelection
|
||||
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.helper.fileSize
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -45,9 +43,9 @@ class ChangeVisualLinesEndAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_MOT_LINEWISE, FLAG_MULTIKEY_UNDO, FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
@@ -58,19 +56,19 @@ class ChangeVisualLinesEndAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
val ends = vimTextRange.endOffsets
|
||||
for (i in starts.indices) {
|
||||
if (ends[i] > starts[i]) {
|
||||
ends[i] = EditorHelper.getLineEndForOffset(editor, starts[i])
|
||||
ends[i] = injector.engineEditorHelper.getLineEndForOffset(editor, starts[i])
|
||||
}
|
||||
}
|
||||
val blockRange = TextRange(starts, ends)
|
||||
VimPlugin.getChange().changeRange(editor, caret, blockRange, SelectionType.BLOCK_WISE, context)
|
||||
injector.changeGroup.changeRange(editor, caret, blockRange, SelectionType.BLOCK_WISE, context)
|
||||
} else {
|
||||
val lineEndForOffset = EditorHelper.getLineEndForOffset(editor, vimTextRange.endOffset)
|
||||
val endsWithNewLine = if (lineEndForOffset == editor.fileSize) 0 else 1
|
||||
val lineEndForOffset = injector.engineEditorHelper.getLineEndForOffset(editor, vimTextRange.endOffset)
|
||||
val endsWithNewLine = if (lineEndForOffset.toLong() == editor.fileSize()) 0 else 1
|
||||
val lineRange = TextRange(
|
||||
EditorHelper.getLineStartForOffset(editor, vimTextRange.startOffset),
|
||||
injector.engineEditorHelper.getLineStartForOffset(editor, vimTextRange.startOffset),
|
||||
lineEndForOffset + endsWithNewLine
|
||||
)
|
||||
VimPlugin.getChange().changeRange(editor, caret, lineRange, SelectionType.LINE_WISE, context)
|
||||
injector.changeGroup.changeRange(editor, caret, lineRange, SelectionType.LINE_WISE, context)
|
||||
}
|
||||
}
|
||||
}
|
@@ -18,17 +18,15 @@
|
||||
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.DuplicableOperatorAction
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.group.MotionGroup
|
||||
import com.maddyhome.idea.vim.handler.VimActionHandler
|
||||
import com.maddyhome.idea.vim.helper.endOffsetInclusive
|
||||
import com.maddyhome.idea.vim.newapi.ij
|
||||
|
||||
class FilterMotionAction : VimActionHandler.SingleExecution(), DuplicableOperatorAction {
|
||||
|
||||
@@ -40,24 +38,19 @@ class FilterMotionAction : VimActionHandler.SingleExecution(), DuplicableOperato
|
||||
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean {
|
||||
val argument = cmd.argument ?: return false
|
||||
val range = MotionGroup
|
||||
.getMotionRange(
|
||||
editor.ij, editor.primaryCaret().ij, context.ij,
|
||||
argument,
|
||||
operatorArguments
|
||||
)
|
||||
val range = injector.motion.getMotionRange(editor, editor.primaryCaret(), context, argument, operatorArguments)
|
||||
?: return false
|
||||
|
||||
val current = editor.ij.caretModel.logicalPosition
|
||||
val current = editor.currentCaret().getLogicalPosition()
|
||||
val start = editor.offsetToLogicalPosition(range.startOffset)
|
||||
val end = editor.offsetToLogicalPosition(range.endOffsetInclusive)
|
||||
if (current.line != start.line) {
|
||||
MotionGroup.moveCaret(editor.ij, editor.primaryCaret().ij, range.startOffset)
|
||||
injector.motion.moveCaret(editor, editor.primaryCaret(), range.startOffset)
|
||||
}
|
||||
|
||||
val count = if (start.line < end.line) end.line - start.line + 1 else 1
|
||||
|
||||
VimPlugin.getProcess().startFilterCommand(editor.ij, context.ij, Argument.EMPTY_COMMAND.copy(rawCount = count))
|
||||
injector.processGroup.startFilterCommand(editor, context, Argument.EMPTY_COMMAND.copy(rawCount = count))
|
||||
|
||||
return true
|
||||
}
|
@@ -17,16 +17,14 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.handler.VimActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import com.maddyhome.idea.vim.helper.exitVisualMode
|
||||
import com.maddyhome.idea.vim.newapi.ij
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -38,8 +36,8 @@ class FilterVisualLinesAction : VimActionHandler.SingleExecution() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE)
|
||||
|
||||
override fun execute(editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean {
|
||||
VimPlugin.getProcess().startFilterCommand(editor.ij, context.ij, cmd)
|
||||
editor.ij.exitVisualMode()
|
||||
injector.processGroup.startFilterCommand(editor, context, cmd)
|
||||
editor.exitVisualModeNative()
|
||||
return true
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.DuplicableOperatorAction
|
||||
@@ -35,13 +35,13 @@ class ReformatCodeMotionAction : ChangeEditorActionHandler.ForEachCaret(), Dupli
|
||||
override val duplicateWith: Char = 'q'
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return argument != null &&
|
||||
VimPlugin.getChange().reformatCodeMotion(editor, caret, context, argument, operatorArguments)
|
||||
injector.changeGroup.reformatCodeMotion(editor, caret, context, argument, operatorArguments)
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -38,14 +38,14 @@ class ReformatCodeVisualAction : VisualOperatorActionHandler.ForEachCaret() {
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE, CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
VimPlugin.getChange().reformatCodeSelection(editor, caret, range)
|
||||
injector.changeGroup.reformatCodeSelection(editor, caret, range)
|
||||
return true
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change.number
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -30,13 +30,13 @@ sealed class IncAction(val inc: Int) : ChangeEditorActionHandler.ForEachCaret()
|
||||
override val type: Command.Type = Command.Type.CHANGE
|
||||
|
||||
override fun execute(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
argument: Argument?,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return VimPlugin.getChange().changeNumber(editor, caret, inc * operatorArguments.count1)
|
||||
return injector.changeGroup.changeNumber(editor, caret, inc * operatorArguments.count1)
|
||||
}
|
||||
}
|
||||
|
@@ -17,10 +17,10 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.action.change.change.number
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.api.ExecutionContext
|
||||
import com.maddyhome.idea.vim.api.VimCaret
|
||||
import com.maddyhome.idea.vim.api.VimEditor
|
||||
import com.maddyhome.idea.vim.api.injector
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
@@ -34,15 +34,14 @@ sealed class IncNumber(val inc: Int, private val avalanche: Boolean) : VisualOpe
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_EXIT_VISUAL)
|
||||
|
||||
override fun executeAction(
|
||||
editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
editor: VimEditor,
|
||||
caret: VimCaret,
|
||||
context: ExecutionContext,
|
||||
cmd: Command,
|
||||
range: VimSelection,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return VimPlugin.getChange()
|
||||
.changeNumberVisualMode(editor, caret, range.toVimTextRange(false), inc * cmd.count, avalanche)
|
||||
return injector.changeGroup.changeNumberVisualMode(editor, caret, range.toVimTextRange(false), inc * cmd.count, avalanche)
|
||||
}
|
||||
}
|
||||
|
@@ -16,9 +16,11 @@ interface EngineEditorHelper {
|
||||
fun updateLastColumn(caret: VimCaret, prevLastColumn: Int)
|
||||
fun getLineEndOffset(editor: VimEditor, line: Int, allowEnd: Boolean): Int
|
||||
fun getLineStartOffset(editor: VimEditor, line: Int): Int
|
||||
fun getLineStartForOffset(editor: VimEditor, line: Int): Int
|
||||
fun getLineEndForOffset(editor: VimEditor, offset: Int): Int
|
||||
fun visualLineToLogicalLine(editor: VimEditor, line: Int): Int
|
||||
fun normalizeLine(editor: VimEditor, line: Int): Int
|
||||
fun getVisualLineAtTopOfScreen(editor: VimEditor): Int
|
||||
fun getApproximateScreenWidth(editor: VimEditor): Int
|
||||
fun handleWithReadonlyFragmentModificationHandler(editor: VimEditor, exception: java.lang.Exception)
|
||||
}
|
@@ -2,6 +2,7 @@ package com.maddyhome.idea.vim.api
|
||||
|
||||
import com.maddyhome.idea.vim.common.EditorLine
|
||||
import com.maddyhome.idea.vim.common.Offset
|
||||
import com.maddyhome.idea.vim.group.visual.VisualChange
|
||||
|
||||
// TODO: 29.12.2021 Split interface to mutable and immutable
|
||||
interface VimCaret {
|
||||
@@ -12,6 +13,7 @@ interface VimCaret {
|
||||
val selectionEnd: Int
|
||||
var vimSelectionStart: Int
|
||||
val vimLeadSelectionOffset: Int
|
||||
var vimLastVisualOperatorRange: VisualChange?
|
||||
fun moveToOffset(offset: Int)
|
||||
fun offsetForLineStartSkipLeading(line: Int): Int
|
||||
fun getLine(): EditorLine.Pointer
|
||||
@@ -20,6 +22,7 @@ interface VimCaret {
|
||||
val isValid: Boolean
|
||||
fun moveToInlayAwareOffset(newOffset: Int)
|
||||
fun vimSetSelection(start: Int, end: Int = start, moveCaretToSelectionEnd: Boolean = false)
|
||||
fun getLogicalPosition(): VimLogicalPosition
|
||||
fun getVisualPosition(): VimVisualPosition
|
||||
val visualLineStart: Int
|
||||
}
|
@@ -17,12 +17,135 @@
|
||||
*/
|
||||
package com.maddyhome.idea.vim.api
|
||||
|
||||
import com.maddyhome.idea.vim.command.Argument
|
||||
import com.maddyhome.idea.vim.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.command.SelectionType
|
||||
import com.maddyhome.idea.vim.common.TextRange
|
||||
import com.maddyhome.idea.vim.group.visual.VimSelection
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import javax.swing.KeyStroke
|
||||
|
||||
interface VimChangeGroup {
|
||||
fun processCommand(editor: VimEditor, cmd: Command)
|
||||
fun processKey(editor: VimEditor, context: ExecutionContext, key: KeyStroke): Boolean
|
||||
fun processKeyInSelectMode(editor: VimEditor, context: ExecutionContext, key: KeyStroke): Boolean
|
||||
fun setInsertRepeat(lines: Int, column: Int, append: Boolean)
|
||||
|
||||
fun insertBeforeCursor(editor: VimEditor, context: ExecutionContext)
|
||||
|
||||
fun insertBeforeFirstNonBlank(editor: VimEditor, context: ExecutionContext)
|
||||
|
||||
fun insertLineStart(editor: VimEditor, context: ExecutionContext)
|
||||
|
||||
fun insertAfterCursor(editor: VimEditor, context: ExecutionContext)
|
||||
|
||||
fun insertAfterLineEnd(editor: VimEditor, context: ExecutionContext)
|
||||
|
||||
fun insertNewLineAbove(editor: VimEditor, context: ExecutionContext)
|
||||
|
||||
fun insertNewLineBelow(editor: VimEditor, context: ExecutionContext)
|
||||
|
||||
fun insertAtPreviousInsert(editor: VimEditor, context: ExecutionContext)
|
||||
|
||||
fun insertPreviousInsert(editor: VimEditor, context: ExecutionContext, exit: Boolean, operatorArguments: OperatorArguments)
|
||||
|
||||
fun insertRegister(editor: VimEditor, context: ExecutionContext, key: Char): Boolean
|
||||
|
||||
fun insertDeleteInsertedText(editor: VimEditor, caret: VimCaret): Boolean
|
||||
|
||||
fun insertDeletePreviousWord(editor: VimEditor, caret: VimCaret): Boolean
|
||||
|
||||
fun initInsert(editor: VimEditor, context: ExecutionContext, mode: CommandState.Mode)
|
||||
|
||||
fun editorCreated(editor: VimEditor?)
|
||||
|
||||
fun editorReleased(editor: VimEditor?)
|
||||
|
||||
fun processEscape(editor: VimEditor, context: ExecutionContext?, operatorArguments: OperatorArguments)
|
||||
|
||||
fun processEnter(editor: VimEditor, context: ExecutionContext)
|
||||
|
||||
fun insertCharacterAroundCursor(editor: VimEditor, caret: VimCaret, dir: Int): Boolean
|
||||
|
||||
fun processPostChangeModeSwitch(editor: VimEditor, context: ExecutionContext, toSwitch: CommandState.Mode)
|
||||
|
||||
fun processInsert(editor: VimEditor?)
|
||||
|
||||
fun processCommand(editor: VimEditor, cmd: Command)
|
||||
|
||||
fun deleteCharacter(editor: VimEditor, caret: VimCaret, count: Int, isChange: Boolean): Boolean
|
||||
|
||||
fun processSingleCommand(editor: VimEditor)
|
||||
|
||||
fun deleteEndOfLine(editor: VimEditor, caret: VimCaret, count: Int): Boolean
|
||||
|
||||
fun deleteJoinLines(editor: VimEditor, caret: VimCaret, count: Int, spaces: Boolean): Boolean
|
||||
|
||||
fun processKey(editor: VimEditor, context: ExecutionContext, key: KeyStroke): Boolean
|
||||
|
||||
fun processKeyInSelectMode(editor: VimEditor, context: ExecutionContext, key: KeyStroke): Boolean
|
||||
|
||||
fun deleteLine(editor: VimEditor, caret: VimCaret, count: Int): Boolean
|
||||
|
||||
fun deleteJoinRange(editor: VimEditor, caret: VimCaret, range: TextRange, spaces: Boolean): Boolean
|
||||
|
||||
fun joinViaIdeaByCount(editor: VimEditor, context: ExecutionContext, count: Int): Boolean
|
||||
|
||||
fun joinViaIdeaBySelections(editor: VimEditor, context: ExecutionContext, caretsAndSelections: Map<VimCaret?, VimSelection?>)
|
||||
|
||||
fun changeReplace(editor: VimEditor, context: ExecutionContext)
|
||||
|
||||
fun changeCharacter(editor: VimEditor, caret: VimCaret, count: Int, ch: Char): Boolean
|
||||
|
||||
fun changeCharacterRange(editor: VimEditor, range: TextRange, ch: Char): Boolean
|
||||
|
||||
fun getDeleteRangeAndType(editor: VimEditor, caret: VimCaret, context: ExecutionContext, argument: Argument, isChange: Boolean, operatorArguments: OperatorArguments): Pair<TextRange?, SelectionType?>?
|
||||
|
||||
fun getDeleteRangeAndType2(editor: VimEditor, caret: VimCaret, context: ExecutionContext, argument: Argument, isChange: Boolean, operatorArguments: OperatorArguments): Pair<TextRange?, SelectionType?>?
|
||||
|
||||
fun deleteRange(editor: VimEditor, caret: VimCaret, range: TextRange, type: SelectionType?, isChange: Boolean): Boolean
|
||||
|
||||
fun changeCharacters(editor: VimEditor, caret: VimCaret, count: Int): Boolean
|
||||
|
||||
fun changeEndOfLine(editor: VimEditor, caret: VimCaret, count: Int): Boolean
|
||||
|
||||
fun changeMotion(editor: VimEditor, caret: VimCaret, context: ExecutionContext, argument: Argument, operatorArguments: OperatorArguments): Boolean
|
||||
|
||||
fun changeCaseToggleCharacter(editor: VimEditor, caret: VimCaret, count: Int): Boolean
|
||||
|
||||
fun blockInsert(editor: VimEditor, context: ExecutionContext, range: TextRange, append: Boolean, operatorArguments: OperatorArguments): Boolean
|
||||
|
||||
fun changeCaseRange(editor: VimEditor, caret: VimCaret, range: TextRange, type: Char): Boolean
|
||||
|
||||
fun changeRange(editor: VimEditor, caret: VimCaret, range: TextRange, type: SelectionType, context: ExecutionContext?): Boolean
|
||||
|
||||
fun changeCaseMotion(editor: VimEditor, caret: VimCaret, context: ExecutionContext?, type: Char, argument: Argument, operatorArguments: OperatorArguments): Boolean
|
||||
|
||||
fun reformatCodeMotion(editor: VimEditor, caret: VimCaret, context: ExecutionContext?, argument: Argument, operatorArguments: OperatorArguments): Boolean
|
||||
|
||||
fun reformatCodeSelection(editor: VimEditor, caret: VimCaret, range: VimSelection)
|
||||
|
||||
fun autoIndentMotion(editor: VimEditor, caret: VimCaret, context: ExecutionContext, argument: Argument, operatorArguments: OperatorArguments)
|
||||
|
||||
fun autoIndentRange(editor: VimEditor, caret: VimCaret, context: ExecutionContext, range: TextRange)
|
||||
|
||||
fun indentLines(editor: VimEditor, caret: VimCaret, context: ExecutionContext, lines: Int, dir: Int)
|
||||
|
||||
fun insertText(editor: VimEditor, caret: VimCaret, offset: Int, str: String)
|
||||
|
||||
fun insertText(editor: VimEditor, caret: VimCaret, str: String)
|
||||
|
||||
fun indentMotion(editor: VimEditor, caret: VimCaret, context: ExecutionContext, argument: Argument, dir: Int, operatorArguments: OperatorArguments)
|
||||
|
||||
fun indentRange(editor: VimEditor, caret: VimCaret, context: ExecutionContext, range: TextRange, count: Int, dir: Int)
|
||||
|
||||
fun changeNumberVisualMode(editor: VimEditor, caret: VimCaret, selectedRange: TextRange, count: Int, avalanche: Boolean): Boolean
|
||||
|
||||
fun changeNumber(editor: VimEditor, caret: VimCaret, count: Int): Boolean
|
||||
|
||||
fun reset()
|
||||
|
||||
fun saveStrokes(newStrokes: String?)
|
||||
|
||||
@TestOnly
|
||||
fun resetRepeat()
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package com.maddyhome.idea.vim.api
|
||||
|
||||
abstract class VimChangeGroupBase : VimChangeGroup {
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user