1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-08-08 18:40:37 +02:00

Remove unnecessary user data (wasVisualBlock)

This commit is contained in:
Alex Plate 2019-04-25 14:56:15 +03:00
parent 1ad9dd4a28
commit 94e4556bee
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
4 changed files with 3 additions and 19 deletions
src/com/maddyhome/idea/vim

View File

@ -29,7 +29,6 @@ import com.maddyhome.idea.vim.command.MappingMode;
import com.maddyhome.idea.vim.command.SelectionType;
import com.maddyhome.idea.vim.common.TextRange;
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler;
import com.maddyhome.idea.vim.helper.EditorData;
import com.maddyhome.idea.vim.helper.EditorHelper;
import com.maddyhome.idea.vim.helper.VimSelection;
import org.jetbrains.annotations.NotNull;
@ -52,7 +51,7 @@ public class ChangeVisualLinesEndAction extends VimCommandAction {
@NotNull Command cmd,
@NotNull VimSelection range) {
TextRange vimTextRange = range.toVimTextRange(true);
if (EditorData.wasVisualBlockMode(editor) && vimTextRange.isMultiple()) {
if (range.getType() == SelectionType.BLOCK_WISE && vimTextRange.isMultiple()) {
final int[] starts = vimTextRange.getStartOffsets();
final int[] ends = vimTextRange.getEndOffsets();
for (int i = 0; i < starts.length; i++) {

View File

@ -24,6 +24,7 @@ import com.maddyhome.idea.vim.helper.EditorData;
import com.maddyhome.idea.vim.key.ParentNode;
import com.maddyhome.idea.vim.option.NumberOption;
import com.maddyhome.idea.vim.option.Options;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -56,6 +57,7 @@ public class CommandState {
myLastChangeRegister = VimPlugin.getRegister().getDefaultRegister();
}
@Contract("null -> new")
@NotNull
public static CommandState getInstance(@Nullable Editor editor) {
if (editor == null) {

View File

@ -64,7 +64,6 @@ sealed class VisualOperatorActionHandler : EditorActionHandlerBase(false) {
logger.debug("execute, cmd=$cmd")
EditorData.setChangeSwitchMode(editor, null)
EditorData.setWasVisualBlockMode(editor, CommandState.inVisualBlockMode(editor))
if (CommandState.getInstance(editor).mode == CommandState.Mode.VISUAL) {
val range = editor.visualBlockRange

View File

@ -205,21 +205,6 @@ public class EditorData {
editor.putUserData(CHANGE_ACTION_SWITCH_MODE, mode);
}
/**
* Sets the visual block mode flag in the beginning of handling visual operator actions
*/
public static boolean wasVisualBlockMode(@NotNull Editor editor) {
Boolean res = editor.getUserData(WAS_VISUAL_BLOCK_MODE);
return res != null && res;
}
/**
* Sets the visual block mode flag in the beginning of handling visual operator actions
*/
public static void setWasVisualBlockMode(@NotNull Editor editor, boolean value) {
editor.putUserData(WAS_VISUAL_BLOCK_MODE, value);
}
/**
* This is a static helper - no instances needed
*/
@ -240,7 +225,6 @@ public class EditorData {
private static final Key<TestInputModel> TEST_INPUT_MODEL = new Key<TestInputModel>("IdeaVim.testInputModel");
private static final Key<Boolean> IS_KEEPING_VISUAL_OPERATOR_ACTION = new Key<>("isKeepingVisualOperatorAction");
private static final Key<CommandState.Mode> CHANGE_ACTION_SWITCH_MODE = new Key<>("changeActionSwitchMode");
private static final Key<Boolean> WAS_VISUAL_BLOCK_MODE = new Key<>("wasVisualBlockMode");
private static final Logger logger = Logger.getInstance(EditorData.class.getName());