mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-04-15 17:15:43 +02:00
Double commands are processed in original way
This commit is contained in:
parent
29ecae66a9
commit
6d4ff752a0
resources/META-INF
src/com/maddyhome/idea/vim
@ -283,7 +283,6 @@
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.delete.DeleteJoinLinesSpacesAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.delete.DeleteJoinVisualLinesAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.delete.DeleteJoinVisualLinesSpacesAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.delete.DeleteLineAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.delete.DeleteMotionAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.delete.DeleteVisualAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.delete.DeleteVisualLinesAction"/>
|
||||
@ -314,20 +313,16 @@
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.change.ChangeVisualLinesAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.change.ChangeVisualLinesEndAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.change.FilterMotionAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.change.FilterCountLinesAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.change.FilterVisualLinesAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.change.AutoIndentLinesVisualAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.change.ReformatCodeVisualAction"/>
|
||||
|
||||
<!-- Shift -->
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.shift.AutoIndentLinesAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.shift.AutoIndentMotionAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.shift.ShiftLeftLinesAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.shift.ShiftLeftLinesNormalModeAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.shift.ShiftLeftMotionAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.shift.ShiftLeftVisualAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.shift.ShiftRightLinesAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.shift.ShiftRightLinesNormalModeAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.shift.ShiftRightMotionAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.change.shift.ShiftRightVisualAction"/>
|
||||
|
||||
@ -340,7 +335,6 @@
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.copy.PutTextBeforeCursorActionMoveCursor"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.copy.SelectRegisterAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.copy.YankLineAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.copy.YankLineMidCountAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.copy.YankMotionAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.copy.YankVisualAction"/>
|
||||
<vimAction implementation="com.maddyhome.idea.vim.action.copy.YankVisualLinesAction"/>
|
||||
|
@ -95,11 +95,13 @@ public class KeyHandler {
|
||||
return origHandler;
|
||||
}
|
||||
|
||||
public static void executeVimAction(@NotNull Editor editor, @NotNull EditorActionHandlerBase cmd, DataContext context) {
|
||||
CommandProcessor.getInstance().executeCommand(editor.getProject(), () -> cmd
|
||||
.execute(editor, getProjectAwareDataContext(editor, context)), cmd.getId(),
|
||||
DocCommandGroupId.noneGroupId(editor.getDocument()),
|
||||
UndoConfirmationPolicy.DEFAULT, editor.getDocument());
|
||||
public static void executeVimAction(@NotNull Editor editor,
|
||||
@NotNull EditorActionHandlerBase cmd,
|
||||
DataContext context) {
|
||||
CommandProcessor.getInstance()
|
||||
.executeCommand(editor.getProject(), () -> cmd.execute(editor, getProjectAwareDataContext(editor, context)),
|
||||
cmd.getId(), DocCommandGroupId.noneGroupId(editor.getDocument()), UndoConfirmationPolicy.DEFAULT,
|
||||
editor.getDocument());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -207,12 +209,14 @@ public class KeyHandler {
|
||||
|
||||
// Ask the key/action tree if this is an appropriate key at this point in the command and if so,
|
||||
// return the node matching this keystroke
|
||||
final Node node = editorState.getCurrentNode().getChildOrArgument(key);
|
||||
Node node = editorState.getCurrentNode().getChildOrArgument(key);
|
||||
|
||||
if (handleDigraph(editor, key, context, node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
node = mapOpCommand(key, node, editorState);
|
||||
|
||||
// If this is a branch node we have entered only part of a multi-key command
|
||||
if (node instanceof BranchNode) {
|
||||
handleBranchNode(editor, context, editorState, chKey, (BranchNode)node);
|
||||
@ -282,6 +286,18 @@ public class KeyHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/** See the description for {@link CommandFlags#FLAG_DUPLICABLE_OPERATOR} */
|
||||
private Node mapOpCommand(KeyStroke key, Node node, @NotNull CommandState editorState) {
|
||||
if (editorState.getMappingMode() == MappingMode.OP_PENDING && !currentCmd.empty()) {
|
||||
EditorActionHandlerBase action = currentCmd.peek().getAction();
|
||||
if (action.getFlags().contains(CommandFlags.FLAG_DUPLICABLE_OPERATOR) &&
|
||||
action.getKeyStrokesSet().stream().anyMatch(o -> o.size() == 1 && o.get(0).equals(key))) {
|
||||
return editorState.getCurrentNode().getChildOrArgument(KeyStroke.getKeyStroke('_'));
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
private static <T> boolean isPrefix(@NotNull List<T> list1, @NotNull List<T> list2) {
|
||||
if (list1.size() > list2.size()) {
|
||||
return false;
|
||||
@ -580,9 +596,11 @@ public class KeyHandler {
|
||||
if (currentArg == Argument.Type.MOTION) {
|
||||
// We have been expecting a motion argument - is this one?
|
||||
if (node.getCmdType() == Command.Type.MOTION) {
|
||||
if (!(node.getAction() instanceof MotionActionHandler) && !(node.getAction() instanceof TextObjectActionHandler)) {
|
||||
throw new RuntimeException("MOTION cmd type can be used only with MotionActionHandler or TextObjectActionHandler - " +
|
||||
node.getAction().getClass().getName());
|
||||
if (!(node.getAction() instanceof MotionActionHandler) &&
|
||||
!(node.getAction() instanceof TextObjectActionHandler)) {
|
||||
throw new RuntimeException(
|
||||
"MOTION cmd type can be used only with MotionActionHandler or TextObjectActionHandler - " +
|
||||
node.getAction().getClass().getName());
|
||||
}
|
||||
// Create the motion command and add it to the stack
|
||||
Command cmd = new Command(count, node.getAction(), node.getCmdType(), node.getFlags());
|
||||
@ -676,10 +694,7 @@ public class KeyHandler {
|
||||
@NotNull CommandState editorState,
|
||||
char key,
|
||||
@NotNull BranchNode node) {
|
||||
// Flag that we aren't allowing any more count digits (unless it's OK)
|
||||
if (!node.getFlags().contains(CommandFlags.FLAG_ALLOW_MID_COUNT)) {
|
||||
state = State.COMMAND;
|
||||
}
|
||||
state = State.COMMAND;
|
||||
editorState.setCurrentNode(node);
|
||||
|
||||
ArgumentNode arg = ((BranchNode)editorState.getCurrentNode()).getArgument();
|
||||
@ -689,7 +704,7 @@ public class KeyHandler {
|
||||
state = State.BAD_COMMAND;
|
||||
return;
|
||||
}
|
||||
if (arg.getArgType() == Argument.Type.CHARACTER || arg.getArgType() == Argument.Type.DIGRAPH ) {
|
||||
if (arg.getArgType() == Argument.Type.CHARACTER || arg.getArgType() == Argument.Type.DIGRAPH) {
|
||||
state = State.CHAR_OR_DIGRAPH;
|
||||
}
|
||||
if (editorState.isRecording() && arg.getFlags().contains(CommandFlags.FLAG_NO_ARG_RECORDING)) {
|
||||
@ -750,7 +765,8 @@ public class KeyHandler {
|
||||
|
||||
// This method is copied from com.intellij.openapi.editor.actionSystem.EditorAction.getProjectAwareDataContext
|
||||
@NotNull
|
||||
private static DataContext getProjectAwareDataContext(@NotNull final Editor editor, @NotNull final DataContext original) {
|
||||
private static DataContext getProjectAwareDataContext(@NotNull final Editor editor,
|
||||
@NotNull final DataContext original) {
|
||||
if (PROJECT.getData(original) == editor.getProject()) {
|
||||
return new DialogAwareDataContext(original);
|
||||
}
|
||||
@ -857,10 +873,7 @@ public class KeyHandler {
|
||||
/**
|
||||
* Awaiting for char or digraph input. In this mode mappings doesn't work (even for <C-K>)
|
||||
*/
|
||||
CHAR_OR_DIGRAPH,
|
||||
READY,
|
||||
ERROR,
|
||||
BAD_COMMAND
|
||||
CHAR_OR_DIGRAPH, READY, ERROR, BAD_COMMAND
|
||||
}
|
||||
|
||||
private int count;
|
||||
|
@ -46,7 +46,7 @@ public class ChangeLineAction extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("cc", "S");
|
||||
return parseKeysSet("S");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@ -58,7 +58,7 @@ public class ChangeLineAction extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@NotNull
|
||||
@Override
|
||||
public EnumSet<CommandFlags> getFlags() {
|
||||
return EnumSet.of(CommandFlags.FLAG_NO_REPEAT, CommandFlags.FLAG_ALLOW_MID_COUNT, CommandFlags.FLAG_MULTIKEY_UNDO);
|
||||
return EnumSet.of(CommandFlags.FLAG_NO_REPEAT, CommandFlags.FLAG_MULTIKEY_UNDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,6 +61,12 @@ public class ChangeMotionAction extends ChangeEditorActionHandler.ForEachCaret {
|
||||
return Argument.Type.MOTION;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnumSet<CommandFlags> getFlags() {
|
||||
return EnumSet.of(CommandFlags.FLAG_DUPLICABLE_OPERATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2019 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.change;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.maddyhome.idea.vim.VimPlugin;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.VimActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class FilterCountLinesAction extends VimActionHandler.SingleExecution {
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("!!");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
VimPlugin.getProcess().startFilterCommand(editor, context, cmd);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -23,10 +23,13 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
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.MappingMode
|
||||
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.helper.enumSetOf
|
||||
import java.util.*
|
||||
import javax.swing.KeyStroke
|
||||
|
||||
|
||||
@ -39,6 +42,8 @@ class FilterMotionAction : VimActionHandler.SingleExecution() {
|
||||
|
||||
override val argumentType: Argument.Type = Argument.Type.MOTION
|
||||
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_DUPLICABLE_OPERATOR)
|
||||
|
||||
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
|
||||
val argument = cmd.argument ?: return false
|
||||
val range = MotionGroup
|
||||
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2019 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.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.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.CommandFlags;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class DeleteLineAction extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("dd");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.DELETE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnumSet<CommandFlags> getFlags() {
|
||||
return EnumSet.of(CommandFlags.FLAG_ALLOW_MID_COUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
@NotNull DataContext context,
|
||||
int count,
|
||||
int rawCount,
|
||||
@Nullable Argument argument) {
|
||||
return VimPlugin.getChange().deleteLine(editor, caret, count);
|
||||
}
|
||||
}
|
@ -22,10 +22,7 @@ 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.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.command.SelectionType;
|
||||
import com.maddyhome.idea.vim.command.*;
|
||||
import com.maddyhome.idea.vim.common.TextRange;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import kotlin.Pair;
|
||||
@ -33,6 +30,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -62,6 +60,12 @@ public class DeleteMotionAction extends ChangeEditorActionHandler.ForEachCaret {
|
||||
return Argument.Type.MOTION;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnumSet<CommandFlags> getFlags() {
|
||||
return EnumSet.of(CommandFlags.FLAG_DUPLICABLE_OPERATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* IdeaVim - Vim emulator for IDEs based on the IntelliJ platform
|
||||
* Copyright (C) 2003-2019 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.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.command.Argument;
|
||||
import com.maddyhome.idea.vim.command.Command;
|
||||
import com.maddyhome.idea.vim.command.MappingMode;
|
||||
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class AutoIndentLinesAction extends ChangeEditorActionHandler.ForEachCaret {
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<MappingMode> getMappingModes() {
|
||||
return MappingMode.N;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<List<KeyStroke>> getKeyStrokesSet() {
|
||||
return parseKeysSet("==");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Command.Type getType() {
|
||||
return Command.Type.CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
@NotNull DataContext context,
|
||||
int count,
|
||||
int rawCount,
|
||||
@Nullable Argument argument) {
|
||||
VimPlugin.getChange().autoIndentLines(editor, caret, context, count);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -63,6 +63,12 @@ public class AutoIndentMotionAction extends ChangeEditorActionHandler.ForEachCar
|
||||
return Argument.Type.MOTION;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnumSet<CommandFlags> getFlags() {
|
||||
return EnumSet.of(CommandFlags.FLAG_DUPLICABLE_OPERATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
|
@ -51,22 +51,3 @@ class ShiftLeftLinesAction : ChangeEditorActionHandler.ForEachCaret() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
class ShiftLeftLinesNormalModeAction : ChangeEditorActionHandler.ForEachCaret() {
|
||||
override val mappingModes: Set<MappingMode> = MappingMode.N
|
||||
|
||||
override val keyStrokesSet: Set<List<KeyStroke>> = parseKeysSet("<<")
|
||||
|
||||
override val type: Command.Type = Command.Type.CHANGE
|
||||
|
||||
override fun execute(editor: Editor,
|
||||
caret: Caret,
|
||||
context: DataContext,
|
||||
count: Int,
|
||||
rawCount: Int,
|
||||
argument: Argument?): Boolean {
|
||||
VimPlugin.getChange().indentLines(editor, caret, context, count, -1)
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,12 @@ public class ShiftLeftMotionAction extends ChangeEditorActionHandler.ForEachCare
|
||||
return Argument.Type.MOTION;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnumSet<CommandFlags> getFlags() {
|
||||
return EnumSet.of(CommandFlags.FLAG_DUPLICABLE_OPERATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
|
@ -51,17 +51,3 @@ class ShiftRightLinesAction : ChangeEditorActionHandler.ForEachCaret() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
class ShiftRightLinesNormalModeAction : ChangeEditorActionHandler.ForEachCaret() {
|
||||
override val mappingModes: Set<MappingMode> = MappingMode.N
|
||||
|
||||
override val keyStrokesSet: Set<List<KeyStroke>> = parseKeysSet(">>")
|
||||
|
||||
override val type: Command.Type = Command.Type.CHANGE
|
||||
|
||||
override fun execute(editor: Editor, caret: Caret, context: DataContext, count: Int,
|
||||
rawCount: Int, argument: Argument?): Boolean {
|
||||
VimPlugin.getChange().indentLines(editor, caret, context, count, 1)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,12 @@ public class ShiftRightMotionAction extends ChangeEditorActionHandler.ForEachCar
|
||||
return Argument.Type.MOTION;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnumSet<CommandFlags> getFlags() {
|
||||
return EnumSet.of(CommandFlags.FLAG_DUPLICABLE_OPERATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
|
@ -22,11 +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.command.Command
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.MappingMode
|
||||
import com.maddyhome.idea.vim.handler.VimActionHandler
|
||||
import com.maddyhome.idea.vim.helper.enumSetOf
|
||||
import java.util.*
|
||||
import javax.swing.KeyStroke
|
||||
|
||||
|
||||
@ -41,17 +38,3 @@ class YankLineAction : VimActionHandler.SingleExecution() {
|
||||
return VimPlugin.getYank().yankLine(editor, cmd.count)
|
||||
}
|
||||
}
|
||||
|
||||
class YankLineMidCountAction : VimActionHandler.SingleExecution() {
|
||||
override val mappingModes: Set<MappingMode> = MappingMode.N
|
||||
|
||||
override val keyStrokesSet: Set<List<KeyStroke>> = parseKeysSet("yy")
|
||||
|
||||
override val type: Command.Type = Command.Type.COPY
|
||||
|
||||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_ALLOW_MID_COUNT)
|
||||
|
||||
override fun execute(editor: Editor, context: DataContext, cmd: Command): Boolean {
|
||||
return VimPlugin.getYank().yankLine(editor, cmd.count)
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,12 @@ public class YankMotionAction extends VimActionHandler.SingleExecution {
|
||||
return Argument.Type.MOTION;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public EnumSet<CommandFlags> getFlags() {
|
||||
return EnumSet.of(CommandFlags.FLAG_DUPLICABLE_OPERATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull Command cmd) {
|
||||
final Argument argument = cmd.getArgument();
|
||||
|
@ -48,11 +48,6 @@ enum class CommandFlags {
|
||||
FLAG_SAVE_STROKE,
|
||||
FLAG_IGNORE_SCROLL_JUMP,
|
||||
FLAG_IGNORE_SIDE_SCROLL_JUMP,
|
||||
/**
|
||||
* Indicates a command can accept a count in mid command
|
||||
* E.g. d2d, c2c
|
||||
*/
|
||||
FLAG_ALLOW_MID_COUNT,
|
||||
/**
|
||||
* Search Flags
|
||||
*/
|
||||
@ -92,5 +87,18 @@ enum class CommandFlags {
|
||||
* and [com.maddyhome.idea.vim.action.window.LookupDownAction] because there actions have custom handler
|
||||
* only if lookup is active.
|
||||
*/
|
||||
FLAG_TYPEAHEAD_SELF_MANAGE
|
||||
FLAG_TYPEAHEAD_SELF_MANAGE,
|
||||
|
||||
/**
|
||||
* There are some double-character commands like `cc`, `dd`, `yy`.
|
||||
* During the execution these commands are replaced with `c_`, `d_`, `y_`, etc.
|
||||
*
|
||||
* This is not any kind of workaround, this is exactly how the original vim works.
|
||||
* The `dd` command (and others) should not be processed as a monolith command, or it will lead to problems
|
||||
* like this: https://youtrack.jetbrains.com/issue/VIM-1189
|
||||
*
|
||||
* If some command has this flag, and the user enters motion operator that is the same as the command itself, the
|
||||
* motion operator will be replaced with `_`.
|
||||
*/
|
||||
FLAG_DUPLICABLE_OPERATOR
|
||||
}
|
||||
|
@ -111,6 +111,7 @@ public class ProcessGroup {
|
||||
CommandParser.getInstance().processCommand(editor, context, text, 1);
|
||||
}
|
||||
else {
|
||||
// FIXME looks like this branch gets never executed
|
||||
int pos = VimPlugin.getSearch().search(editor, text, panel.getCount(),
|
||||
panel.getLabel().equals("/")
|
||||
? EnumSet.of(CommandFlags.FLAG_SEARCH_FWD)
|
||||
|
@ -129,7 +129,7 @@
|
||||
* |CTRL-\CTRL-N| {@link com.maddyhome.idea.vim.action.ResetModeAction}
|
||||
* |<Space>| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionRightWrapAction}
|
||||
* |!| {@link com.maddyhome.idea.vim.action.change.change.FilterMotionAction}
|
||||
* |!!| {@link com.maddyhome.idea.vim.action.change.change.FilterCountLinesAction}
|
||||
* |!!| translated to !_
|
||||
* |quote| {@link com.maddyhome.idea.vim.action.copy.SelectRegisterAction}
|
||||
* |#| {@link com.maddyhome.idea.vim.action.motion.search.SearchWholeWordBackwardAction}
|
||||
* |$| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionLastColumnAction}
|
||||
@ -149,11 +149,11 @@
|
||||
* |:| {@link com.maddyhome.idea.vim.action.ExEntryAction}
|
||||
* |;| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionLastMatchCharAction}
|
||||
* |<| {@link com.maddyhome.idea.vim.action.change.shift.ShiftLeftMotionAction}
|
||||
* |<<| {@link com.maddyhome.idea.vim.action.change.shift.ShiftLeftLinesNormalModeAction}
|
||||
* |<<| translated to <_
|
||||
* |=| {@link com.maddyhome.idea.vim.action.change.shift.AutoIndentMotionAction}
|
||||
* |==| {@link com.maddyhome.idea.vim.action.change.shift.AutoIndentLinesAction}
|
||||
* |==| translated to =_
|
||||
* |>| {@link com.maddyhome.idea.vim.action.change.shift.ShiftRightMotionAction}
|
||||
* |>>| {@link com.maddyhome.idea.vim.action.change.shift.ShiftRightLinesNormalModeAction}
|
||||
* |>>| translated to >_
|
||||
* |?| {@link com.maddyhome.idea.vim.action.motion.search.SearchEntryRevAction}
|
||||
* |@| {@link com.maddyhome.idea.vim.action.macro.PlaybackRegisterAction}
|
||||
* |@:| {@link com.maddyhome.idea.vim.action.change.RepeatExCommandAction}
|
||||
@ -196,9 +196,9 @@
|
||||
* |a| {@link com.maddyhome.idea.vim.action.change.insert.InsertAfterCursorAction}
|
||||
* |b| {@link com.maddyhome.idea.vim.action.motion.text.MotionWordLeftAction}
|
||||
* |c| {@link com.maddyhome.idea.vim.action.change.change.ChangeMotionAction}
|
||||
* |cc| {@link com.maddyhome.idea.vim.action.change.change.ChangeLineAction}
|
||||
* |cc| translated to c_
|
||||
* |d| {@link com.maddyhome.idea.vim.action.change.delete.DeleteMotionAction}
|
||||
* |dd| {@link com.maddyhome.idea.vim.action.change.delete.DeleteLineAction}
|
||||
* |dd| translated to d_
|
||||
* |do| TODO
|
||||
* |dp| TODO
|
||||
* |e| {@link com.maddyhome.idea.vim.action.motion.text.MotionWordEndRightAction}
|
||||
@ -222,7 +222,7 @@
|
||||
* |w| {@link com.maddyhome.idea.vim.action.motion.text.MotionWordRightAction}
|
||||
* |x| {@link com.maddyhome.idea.vim.action.change.delete.DeleteCharacterRightAction}
|
||||
* |y| {@link com.maddyhome.idea.vim.action.copy.YankMotionAction}
|
||||
* |yy| {@link com.maddyhome.idea.vim.action.copy.YankLineMidCountAction}
|
||||
* |yy| translated to y_
|
||||
* |z| see commands starting with 'z'
|
||||
* |{| {@link com.maddyhome.idea.vim.action.motion.text.MotionParagraphPreviousAction}
|
||||
* |bar| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionColumnAction}
|
||||
|
Loading…
Reference in New Issue
Block a user