1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-01-11 19:42:46 +01:00

Fix problem with exiting from the insert mode. Actually if we turn insert mode on for some editors, they don't have any lastinsert

This commit is contained in:
Oleg Shpynov 2011-03-29 12:29:06 +04:00
parent 1461a2b29f
commit b3eab0cb39

View File

@ -1,23 +1,19 @@
package com.maddyhome.idea.vim.group;
/*
* IdeaVim - A Vim emulator plugin for IntelliJ Idea
* Copyright (C) 2003-2006 Rick Maddy
* Copyright 2000-2011 JetBrains s.r.o.
*
* 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.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* 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.
* http://www.apache.org/licenses/LICENSE-2.0
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.maddyhome.idea.vim.group;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
@ -463,11 +459,7 @@ public class ChangeGroup extends AbstractActionGroup {
*/
public void processEscape(Editor editor, DataContext context) {
logger.debug("processing escape");
// Prevent possible NPE
if (lastInsert == null){
return;
}
int cnt = lastInsert.getCount();
int cnt = lastInsert != null ? lastInsert.getCount() : 0;
// Turn off overwrite mode if we were in replace mode
if (CommandState.getInstance(editor).getMode() == CommandState.MODE_REPLACE) {
KeyHandler.executeAction("VimInsertReplaceToggle", context);
@ -480,11 +472,8 @@ public class ChangeGroup extends AbstractActionGroup {
// Save off current list of keystrokes
lastStrokes = new ArrayList(strokes);
// TODO - support . register
//CommandGroups.getInstance().getRegister().storeKeys(lastStrokes, Command.FLAG_MOT_CHARACTERWISE, '.');
// If the insert/replace command was preceded by a count, repeat again N - 1 times
repeatInsert(editor, context, cnt - 1, true);
repeatInsert(editor, context, cnt == 0 ? 0 : cnt - 1, true);
CommandGroups.getInstance().getMark().setMark(editor, context, '^', editor.getCaretModel().getOffset());
CommandGroups.getInstance().getMark().setMark(editor, context, ']', editor.getCaretModel().getOffset());