mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-06 12:34:03 +02:00
Update docs and remove unnecessary null parameter
This commit is contained in:
parent
9306d93cbf
commit
e299b27a5c
vim-engine/src/main/kotlin/com/maddyhome/idea/vim
action/motion/visual
api
@ -24,8 +24,8 @@ import com.maddyhome.idea.vim.options.OptionConstants
|
||||
|
||||
@CommandOrMotion(keys = ["V"], modes = [Mode.NORMAL, Mode.VISUAL])
|
||||
class VisualToggleLineModeAction : VimActionHandler.ConditionalMulticaret() {
|
||||
|
||||
override val type: Command.Type = Command.Type.OTHER_READONLY
|
||||
|
||||
override fun runAsMulticaret(
|
||||
editor: VimEditor,
|
||||
context: ExecutionContext,
|
||||
@ -57,7 +57,6 @@ class VisualToggleLineModeAction : VimActionHandler.ConditionalMulticaret() {
|
||||
cmd: Command,
|
||||
operatorArguments: OperatorArguments,
|
||||
): Boolean {
|
||||
return injector.visualMotionGroup
|
||||
.toggleVisual(editor, cmd.count, cmd.rawCount, SelectionType.LINE_WISE)
|
||||
return injector.visualMotionGroup.toggleVisual(editor, cmd.count, cmd.rawCount, SelectionType.LINE_WISE)
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,9 @@ interface VimVisualMotionGroup {
|
||||
val selectionAdj: Int
|
||||
|
||||
/**
|
||||
* This function toggles visual mode.
|
||||
* This function toggles visual mode according to the logic required for `v`, `V` and `<C-V>`
|
||||
*
|
||||
* This is the implementation for `v`, `V` and `<C-V>`. If you need to enter Visual mode, use [enterVisualMode].
|
||||
*
|
||||
* * If visual mode is disabled, enable it
|
||||
* * If visual mode is enabled, but [selectionType] differs, update visual according to new [selectionType]
|
||||
@ -37,21 +39,12 @@ interface VimVisualMotionGroup {
|
||||
fun enterSelectMode(editor: VimEditor, selectionType: SelectionType): Boolean
|
||||
|
||||
/**
|
||||
* Enters visual mode based on current editor state.
|
||||
* Enters Visual mode, ensuring that the caret's selection start offset is correctly set
|
||||
*
|
||||
* If [selectionType] is null, it will be detected automatically
|
||||
*
|
||||
* it:
|
||||
* - Updates command state
|
||||
* - Updates [VimCaret.vimSelectionStart] property
|
||||
* - Updates caret colors
|
||||
* - Updates care shape
|
||||
*
|
||||
* - DOES NOT change selection
|
||||
* - DOES NOT move caret
|
||||
* - DOES NOT check if carets actually have any selection
|
||||
* Use this to programmatically enter Visual mode. Note that it does not modify the editor's selection.
|
||||
*/
|
||||
fun enterVisualMode(editor: VimEditor, selectionType: SelectionType? = null): Boolean
|
||||
fun enterVisualMode(editor: VimEditor, selectionType: SelectionType): Boolean
|
||||
|
||||
fun detectSelectionType(editor: VimEditor): SelectionType
|
||||
|
||||
/**
|
||||
|
@ -43,11 +43,13 @@ abstract class VimVisualMotionGroupBase : VimVisualMotionGroup {
|
||||
}
|
||||
|
||||
/**
|
||||
* This function toggles visual mode.
|
||||
* This function toggles visual mode according to the logic required for `v`, `V` and `<C-V>`
|
||||
*
|
||||
* If visual mode is disabled, enable it
|
||||
* If visual mode is enabled, but [selectionType] differs, update visual according to new [selectionType]
|
||||
* If visual mode is enabled with the same [selectionType], disable it
|
||||
* This is the implementation for `v`, `V` and `<C-V>`. If you need to enter Visual mode, use [enterVisualMode].
|
||||
*
|
||||
* * If visual mode is disabled, enable it
|
||||
* * If visual mode is enabled, but [selectionType] differs, update visual according to new [selectionType]
|
||||
* * If visual mode is enabled with the same [selectionType], disable it
|
||||
*/
|
||||
override fun toggleVisual(
|
||||
editor: VimEditor,
|
||||
@ -146,28 +148,16 @@ abstract class VimVisualMotionGroupBase : VimVisualMotionGroup {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enters visual mode based on current editor state.
|
||||
* Enters Visual mode, ensuring that the caret's selection start offset is correctly set
|
||||
*
|
||||
* If [selectionType] is null, it will be detected automatically
|
||||
*
|
||||
* it:
|
||||
* - Updates command state
|
||||
* - Updates [ImmutableVimCaret.vimSelectionStart] property
|
||||
* - Updates caret colors
|
||||
* - Updates care shape
|
||||
*
|
||||
* - DOES NOT change selection
|
||||
* - DOES NOT move caret
|
||||
* - DOES NOT check if carets actually have any selection
|
||||
* Use this to programmatically enter Visual mode. Note that it does not modify the editor's selection.
|
||||
*/
|
||||
override fun enterVisualMode(editor: VimEditor, selectionType: SelectionType?): Boolean {
|
||||
val newSelectionType = selectionType ?: detectSelectionType(editor)
|
||||
|
||||
editor.mode = Mode.VISUAL(newSelectionType)
|
||||
override fun enterVisualMode(editor: VimEditor, selectionType: SelectionType): Boolean {
|
||||
editor.mode = Mode.VISUAL(selectionType)
|
||||
|
||||
// vimLeadSelectionOffset requires read action
|
||||
injector.application.runReadAction {
|
||||
if (newSelectionType == SelectionType.BLOCK_WISE) {
|
||||
if (selectionType == SelectionType.BLOCK_WISE) {
|
||||
editor.primaryCaret().run { vimSelectionStart = vimLeadSelectionOffset }
|
||||
} else {
|
||||
editor.nativeCarets().forEach { it.vimSelectionStart = it.vimLeadSelectionOffset }
|
||||
|
Loading…
Reference in New Issue
Block a user