mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-17 16:31:45 +02:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
421ce832dd | ||
![]() |
987781f826 | ||
![]() |
d85a41ea98 | ||
![]() |
42f86a3f73 | ||
![]() |
0241b58777 | ||
![]() |
97a2c73efe | ||
![]() |
5f1e46ca82 | ||
![]() |
805779144e | ||
![]() |
c65e21708c | ||
![]() |
08e546b677 | ||
![]() |
11cf8454ad | ||
![]() |
c3494803dc | ||
![]() |
c84496b942 |
23
CHANGES.md
23
CHANGES.md
@@ -4,6 +4,29 @@ The Changelog
|
|||||||
History of changes in IdeaVim for the IntelliJ platform.
|
History of changes in IdeaVim for the IntelliJ platform.
|
||||||
|
|
||||||
|
|
||||||
|
0.29, TBD
|
||||||
|
---------
|
||||||
|
|
||||||
|
A bugfix release.
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* VIM-482 Fixed repeat buffer limits
|
||||||
|
* VIM-91 Enable normal `<Enter>` handling for one-line editors
|
||||||
|
* VIM-121 Don't move cursor while scrolling
|
||||||
|
|
||||||
|
|
||||||
|
0.28, 2013-04-06
|
||||||
|
----------------
|
||||||
|
|
||||||
|
A bugfix release.
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* VIM-478 Fixed reconfigure Vim keymap for user-defined base keymaps
|
||||||
|
* VIM-479 Don't try to activate insert mode for diff view
|
||||||
|
|
||||||
|
|
||||||
0.27, 2013-04-03
|
0.27, 2013-04-03
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
version-id:0.27
|
version-id:0.29
|
||||||
platform-version:110.0
|
platform-version:110.0
|
||||||
idea.download.url=http://download.jetbrains.com/idea/ideaIU-12.0.zip
|
idea.download.url=http://download.jetbrains.com/idea/ideaIU-12.1.zip
|
||||||
build.number=x
|
build.number=x
|
||||||
|
@@ -3,6 +3,16 @@
|
|||||||
<id>IdeaVIM</id>
|
<id>IdeaVIM</id>
|
||||||
<change-notes>
|
<change-notes>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
|
<p>0.29:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Fixed repeat buffer limits</li>
|
||||||
|
<li>Enable normal <code><Enter></code> handling for one-line editors</li>
|
||||||
|
<li>Don't move cursor while scrolling</li>
|
||||||
|
</ul>
|
||||||
|
<p>0.28:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Fixed reconfigure Vim keymap for user-defined base keymaps</li>
|
||||||
|
</ul>
|
||||||
<p>0.27:</p>
|
<p>0.27:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Better Vim keymaps for Mac OS X</li>
|
<li>Better Vim keymaps for Mac OS X</li>
|
||||||
@@ -17,15 +27,6 @@
|
|||||||
<li>New shortcuts for Go to declaration <code><C-]></code> and Navigate back <code><C-T></code></li>
|
<li>New shortcuts for Go to declaration <code><C-]></code> and Navigate back <code><C-T></code></li>
|
||||||
<li>Various bug fixes</li>
|
<li>Various bug fixes</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>0.25:</p>
|
|
||||||
<ul>
|
|
||||||
<li>Various bug fixes</li>
|
|
||||||
</ul>
|
|
||||||
<p>0.24:</p>
|
|
||||||
<ul>
|
|
||||||
<li>Added Vim string object selection motions (see help topics <code>v_i"</code>, <code>v_a"</code>)</li>
|
|
||||||
<li>Various bug fixes</li>
|
|
||||||
</ul>
|
|
||||||
<p>See also the complete <a href="https://github.com/JetBrains/ideavim/blob/master/CHANGES.md">changelog</a>.</p>
|
<p>See also the complete <a href="https://github.com/JetBrains/ideavim/blob/master/CHANGES.md">changelog</a>.</p>
|
||||||
]]>
|
]]>
|
||||||
</change-notes>
|
</change-notes>
|
||||||
|
@@ -6,24 +6,19 @@ import com.google.common.io.Resources;
|
|||||||
import com.intellij.notification.Notification;
|
import com.intellij.notification.Notification;
|
||||||
import com.intellij.notification.NotificationType;
|
import com.intellij.notification.NotificationType;
|
||||||
import com.intellij.notification.Notifications;
|
import com.intellij.notification.Notifications;
|
||||||
|
import com.intellij.openapi.actionSystem.Shortcut;
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
|
||||||
import com.intellij.openapi.application.PathManager;
|
import com.intellij.openapi.application.PathManager;
|
||||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
|
||||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
|
||||||
import com.intellij.openapi.components.impl.stores.StorageUtil;
|
import com.intellij.openapi.components.impl.stores.StorageUtil;
|
||||||
import com.intellij.openapi.diagnostic.Logger;
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
import com.intellij.openapi.keymap.Keymap;
|
import com.intellij.openapi.keymap.Keymap;
|
||||||
import com.intellij.openapi.keymap.KeymapManager;
|
import com.intellij.openapi.keymap.KeymapManager;
|
||||||
import com.intellij.openapi.keymap.impl.KeymapImpl;
|
import com.intellij.openapi.keymap.impl.KeymapImpl;
|
||||||
import com.intellij.openapi.keymap.impl.KeymapManagerImpl;
|
import com.intellij.openapi.keymap.impl.KeymapManagerImpl;
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.intellij.openapi.ui.DialogWrapper;
|
import com.intellij.openapi.ui.DialogWrapper;
|
||||||
import com.intellij.openapi.ui.Messages;
|
|
||||||
import com.intellij.openapi.util.InvalidDataException;
|
import com.intellij.openapi.util.InvalidDataException;
|
||||||
import com.intellij.openapi.util.JDOMUtil;
|
import com.intellij.openapi.util.JDOMUtil;
|
||||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
|
||||||
import com.maddyhome.idea.vim.ui.VimKeymapDialog;
|
import com.maddyhome.idea.vim.ui.VimKeymapDialog;
|
||||||
import org.jdom.Document;
|
import org.jdom.Document;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
@@ -31,6 +26,9 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static com.google.common.io.ByteStreams.toByteArray;
|
import static com.google.common.io.ByteStreams.toByteArray;
|
||||||
|
|
||||||
@@ -67,9 +65,11 @@ public class VimKeyMapUtil {
|
|||||||
final byte[] bytes = toByteArray(retrieveSourceKeymapStream());
|
final byte[] bytes = toByteArray(retrieveSourceKeymapStream());
|
||||||
Files.write(bytes, new File(INSTALLED_VIM_KEYMAP_PATH));
|
Files.write(bytes, new File(INSTALLED_VIM_KEYMAP_PATH));
|
||||||
final Document document = StorageUtil.loadDocument(bytes);
|
final Document document = StorageUtil.loadDocument(bytes);
|
||||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
if (document != null && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||||
// Prompt user to select the parent for the Vim keyboard
|
// Prompt user to select the parent for the Vim keyboard
|
||||||
configureVimParentKeymap(INSTALLED_VIM_KEYMAP_PATH, document, true);
|
if (!configureVimParentKeymap(INSTALLED_VIM_KEYMAP_PATH, document, true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
installKeymap(document);
|
installKeymap(document);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -97,48 +97,53 @@ public class VimKeyMapUtil {
|
|||||||
keymapManager.addKeymap(vimKeyMap);
|
keymapManager.addKeymap(vimKeyMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void requestRestartOrShutdown(final Project project) {
|
|
||||||
final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
|
|
||||||
if (app.isRestartCapable()) {
|
|
||||||
if (Messages.showDialog(project, "Restart " + ApplicationNamesInfo.getInstance().getProductName() + " to activate changes?",
|
|
||||||
VimPlugin.IDEAVIM_NOTIFICATION_TITLE, new String[]{"&Restart", "&Postpone"}, 0,
|
|
||||||
Messages.getQuestionIcon()) == 0) {
|
|
||||||
app.restart();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (Messages.showDialog(project, "Shut down " + ApplicationNamesInfo.getInstance().getProductName() + " to activate changes?",
|
|
||||||
VimPlugin.IDEAVIM_NOTIFICATION_TITLE, new String[]{"&Shut Down", "&Postpone"}, 0,
|
|
||||||
Messages.getQuestionIcon()) == 0) {
|
|
||||||
app.exit(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes parent keymap for the Vim
|
* Changes parent keymap for the Vim
|
||||||
*
|
*
|
||||||
* @return true if document was changed successfully
|
* @return true if document was changed successfully
|
||||||
*/
|
*/
|
||||||
private static boolean configureVimParentKeymap(final String path, @NotNull final Document document, final boolean showNotification) throws IOException {
|
private static boolean configureVimParentKeymap(final String path, @NotNull final Document document,
|
||||||
|
final boolean showNotification)
|
||||||
|
throws IOException, InvalidDataException {
|
||||||
final Element rootElement = document.getRootElement();
|
final Element rootElement = document.getRootElement();
|
||||||
final String parentKeymap = rootElement.getAttributeValue("parent");
|
final String parentKeymapName = rootElement.getAttributeValue("parent");
|
||||||
final VimKeymapDialog vimKeymapDialog = new VimKeymapDialog(parentKeymap);
|
final VimKeymapDialog vimKeymapDialog = new VimKeymapDialog(parentKeymapName);
|
||||||
vimKeymapDialog.show();
|
vimKeymapDialog.show();
|
||||||
if (vimKeymapDialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
|
if (vimKeymapDialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
rootElement.removeAttribute("parent");
|
rootElement.removeAttribute("parent");
|
||||||
final Keymap selectedKeymap = vimKeymapDialog.getSelectedKeymap();
|
final Keymap parentKeymap = vimKeymapDialog.getSelectedKeymap();
|
||||||
final String keymapName = selectedKeymap.getName();
|
final String keymapName = parentKeymap.getName();
|
||||||
rootElement.setAttribute("parent", keymapName);
|
VimKeymapConflictResolveUtil.resolveConflicts(rootElement, parentKeymap);
|
||||||
|
// We cannot set a user-defined modifiable keymap as the parent of our Vim keymap so we have to copy its shortcuts
|
||||||
|
if (parentKeymap.canModify()) {
|
||||||
|
final KeymapImpl vimKeyMap = new KeymapImpl();
|
||||||
|
final KeymapManager keymapManager = KeymapManager.getInstance();
|
||||||
|
final KeymapManagerImpl keymapManagerImpl = (KeymapManagerImpl)keymapManager;
|
||||||
|
final Keymap[] allKeymaps = keymapManagerImpl.getAllKeymaps();
|
||||||
|
vimKeyMap.readExternal(rootElement, allKeymaps);
|
||||||
|
final HashSet<String> ownActions = new HashSet<String>(Arrays.asList(vimKeyMap.getOwnActionIds()));
|
||||||
|
final KeymapImpl parentKeymapImpl = (KeymapImpl)parentKeymap;
|
||||||
|
for (String parentAction : parentKeymapImpl.getOwnActionIds()) {
|
||||||
|
if (!ownActions.contains(parentAction)) {
|
||||||
|
final List<Shortcut> shortcuts = Arrays.asList(parentKeymap.getShortcuts(parentAction));
|
||||||
|
rootElement.addContent(VimKeymapConflictResolveUtil.createActionElement(parentAction, shortcuts));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final Keymap grandParentKeymap = parentKeymap.getParent();
|
||||||
|
rootElement.setAttribute("parent", grandParentKeymap.getName());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rootElement.setAttribute("parent", keymapName);
|
||||||
|
}
|
||||||
VimPlugin.getInstance().setPreviousKeyMap(keymapName);
|
VimPlugin.getInstance().setPreviousKeyMap(keymapName);
|
||||||
VimKeymapConflictResolveUtil.resolveConflicts(rootElement, selectedKeymap);
|
|
||||||
// Save modified keymap to the file
|
// Save modified keymap to the file
|
||||||
JDOMUtil.writeDocument(document, path, "\n");
|
JDOMUtil.writeDocument(document, path, "\n");
|
||||||
if (showNotification) {
|
if (showNotification) {
|
||||||
Notifications.Bus.notify(new Notification(VimPlugin.IDEAVIM_NOTIFICATION_ID, VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
|
Notifications.Bus.notify(new Notification(VimPlugin.IDEAVIM_NOTIFICATION_ID, VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
|
||||||
"Successfully configured vim keymap to be based on " +
|
"Successfully configured vim keymap to be based on " +
|
||||||
selectedKeymap.getPresentableName(),
|
parentKeymap.getPresentableName(),
|
||||||
NotificationType.INFORMATION));
|
NotificationType.INFORMATION));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,9 +219,4 @@ public class VimKeyMapUtil {
|
|||||||
Notifications.Bus.notify(new Notification(VimPlugin.IDEAVIM_NOTIFICATION_ID, VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
|
Notifications.Bus.notify(new Notification(VimPlugin.IDEAVIM_NOTIFICATION_ID, VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
|
||||||
message + String.valueOf(e), NotificationType.ERROR));
|
message + String.valueOf(e), NotificationType.ERROR));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static VirtualFile getVimKeymapFile() {
|
|
||||||
return LocalFileSystem.getInstance().refreshAndFindFileByPath(INSTALLED_VIM_KEYMAP_PATH);
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -160,14 +160,21 @@ public class VimKeymapConflictResolveUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Element createActionElement(String actionName, List<Shortcut> shortcuts) {
|
public static Element createActionElement(String actionName, List<Shortcut> shortcuts) {
|
||||||
final Element overridesAction = new Element(ACTION_TAG);
|
final Element overridesAction = new Element(ACTION_TAG);
|
||||||
overridesAction.setAttribute(ID_ATTRIBUTE, actionName);
|
overridesAction.setAttribute(ID_ATTRIBUTE, actionName);
|
||||||
for (Shortcut shortcut : shortcuts) {
|
for (Shortcut shortcut : shortcuts) {
|
||||||
if (shortcut instanceof KeyboardShortcut) {
|
if (shortcut instanceof KeyboardShortcut) {
|
||||||
KeyboardShortcut keyboardShortcut = (KeyboardShortcut)shortcut;
|
KeyboardShortcut keyboardShortcut = (KeyboardShortcut)shortcut;
|
||||||
overridesAction
|
final String firstShortcutString = KeymapImpl.getKeyShortcutString(keyboardShortcut.getFirstKeyStroke());
|
||||||
.addContent(createShortcutElement(KEYBOARD_SHORTCUT_TAG, FIRST_KEYSTROKE_ATTRIBUTE, KeymapImpl.getKeyShortcutString(keyboardShortcut.getFirstKeyStroke())));
|
final Element shortcutElement = createShortcutElement(KEYBOARD_SHORTCUT_TAG, FIRST_KEYSTROKE_ATTRIBUTE,
|
||||||
|
firstShortcutString);
|
||||||
|
overridesAction.addContent(shortcutElement);
|
||||||
|
final KeyStroke secondKeyStroke = keyboardShortcut.getSecondKeyStroke();
|
||||||
|
if (secondKeyStroke != null) {
|
||||||
|
final String secondShortcutString = KeymapImpl.getKeyShortcutString(secondKeyStroke);
|
||||||
|
shortcutElement.setAttribute(SECOND_KEYSTROKE_ATTRIBUTE, secondShortcutString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (shortcut instanceof MouseShortcut) {
|
else if (shortcut instanceof MouseShortcut) {
|
||||||
overridesAction.addContent(createShortcutElement(MOUSE_SHORTCUT_TAG, KEYSTROKE_ATTRIBUTE, getMouseShortcutString((MouseShortcut)shortcut)));
|
overridesAction.addContent(createShortcutElement(MOUSE_SHORTCUT_TAG, KEYSTROKE_ATTRIBUTE, getMouseShortcutString((MouseShortcut)shortcut)));
|
||||||
|
@@ -167,7 +167,7 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
|||||||
private void updateState() {
|
private void updateState() {
|
||||||
if (isEnabled() && !ApplicationManager.getApplication().isUnitTestMode()) {
|
if (isEnabled() && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||||
boolean requiresRestart = false;
|
boolean requiresRestart = false;
|
||||||
if (previousStateVersion < 1 && VimKeyMapUtil.isVimKeymapInstalled()) {
|
if (previousStateVersion < 1 && SystemInfo.isMac && VimKeyMapUtil.isVimKeymapInstalled()) {
|
||||||
if (Messages.showYesNoDialog("Vim keymap generator has been updated to create keymaps more compatible " +
|
if (Messages.showYesNoDialog("Vim keymap generator has been updated to create keymaps more compatible " +
|
||||||
"with base keymaps.\n\nDo you want to reconfigure your Vim keymap?\n\n" +
|
"with base keymaps.\n\nDo you want to reconfigure your Vim keymap?\n\n" +
|
||||||
"Warning: Any custom shortcuts will be lost!\n\n" +
|
"Warning: Any custom shortcuts will be lost!\n\n" +
|
||||||
@@ -250,7 +250,8 @@ public class VimPlugin implements ApplicationComponent, PersistentStateComponent
|
|||||||
|
|
||||||
if (VimPlugin.isEnabled()) {
|
if (VimPlugin.isEnabled()) {
|
||||||
// Turn on insert mode if editor doesn't have any file
|
// Turn on insert mode if editor doesn't have any file
|
||||||
if (!EditorData.isFileEditor(editor) && !CommandState.inInsertMode(editor)) {
|
if (!EditorData.isFileEditor(editor) && editor.getDocument().isWritable() &&
|
||||||
|
!CommandState.inInsertMode(editor)) {
|
||||||
KeyHandler.getInstance().handleKey(editor, KeyStroke.getKeyStroke('i'), new EditorDataContext(editor));
|
KeyHandler.getInstance().handleKey(editor, KeyStroke.getKeyStroke('i'), new EditorDataContext(editor));
|
||||||
}
|
}
|
||||||
editor.getSettings().setBlockCursor(!CommandState.inInsertMode(editor));
|
editor.getSettings().setBlockCursor(!CommandState.inInsertMode(editor));
|
||||||
|
@@ -36,12 +36,7 @@ public class InsertEnterAction extends EditorAction {
|
|||||||
|
|
||||||
private static class Handler extends EditorActionHandler {
|
private static class Handler extends EditorActionHandler {
|
||||||
public void execute(Editor editor, @NotNull DataContext context) {
|
public void execute(Editor editor, @NotNull DataContext context) {
|
||||||
editor = InjectedLanguageUtil.getTopLevelEditor(editor);
|
CommandGroups.getInstance().getChange().processEnter(InjectedLanguageUtil.getTopLevelEditor(editor), context);
|
||||||
if (editor.isOneLineMode()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandGroups.getInstance().getChange().processEnter(editor, context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -56,6 +56,9 @@ import java.util.List;
|
|||||||
* TODO - change cursor for the different modes
|
* TODO - change cursor for the different modes
|
||||||
*/
|
*/
|
||||||
public class ChangeGroup extends AbstractActionGroup {
|
public class ChangeGroup extends AbstractActionGroup {
|
||||||
|
|
||||||
|
public static final int MAX_REPEAT_CHARS_COUNT = 10000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the group
|
* Creates the group
|
||||||
*/
|
*/
|
||||||
@@ -358,6 +361,7 @@ public class ChangeGroup extends AbstractActionGroup {
|
|||||||
else {
|
else {
|
||||||
lastInsert = state.getCommand();
|
lastInsert = state.getCommand();
|
||||||
strokes.clear();
|
strokes.clear();
|
||||||
|
repeatCharsCount = 0;
|
||||||
if (document != null && documentListener != null) {
|
if (document != null && documentListener != null) {
|
||||||
document.removeDocumentListener(documentListener);
|
document.removeDocumentListener(documentListener);
|
||||||
}
|
}
|
||||||
@@ -381,6 +385,11 @@ public class ChangeGroup extends AbstractActionGroup {
|
|||||||
final String newFragment = e.getNewFragment().toString();
|
final String newFragment = e.getNewFragment().toString();
|
||||||
final String oldFragment = e.getOldFragment().toString();
|
final String oldFragment = e.getOldFragment().toString();
|
||||||
|
|
||||||
|
// Repeat buffer limits
|
||||||
|
if (repeatCharsCount > MAX_REPEAT_CHARS_COUNT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// <Enter> is added to strokes as an action during processing in order to indent code properly in the repeat
|
// <Enter> is added to strokes as an action during processing in order to indent code properly in the repeat
|
||||||
// command
|
// command
|
||||||
if (newFragment.startsWith("\n") && newFragment.trim().isEmpty()) {
|
if (newFragment.startsWith("\n") && newFragment.trim().isEmpty()) {
|
||||||
@@ -409,9 +418,8 @@ public class ChangeGroup extends AbstractActionGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (char c : newFragment.toCharArray()) {
|
strokes.add(newFragment.toCharArray());
|
||||||
strokes.add(c);
|
repeatCharsCount += newFragment.length();
|
||||||
}
|
|
||||||
|
|
||||||
if (newFragment.length() > 0) {
|
if (newFragment.length() > 0) {
|
||||||
// TODO: If newFragment is shorter than oldFragment?
|
// TODO: If newFragment is shorter than oldFragment?
|
||||||
@@ -486,8 +494,11 @@ public class ChangeGroup extends AbstractActionGroup {
|
|||||||
KeyHandler.executeAction((AnAction)lastStroke, context);
|
KeyHandler.executeAction((AnAction)lastStroke, context);
|
||||||
strokes.add(lastStroke);
|
strokes.add(lastStroke);
|
||||||
}
|
}
|
||||||
else if (lastStroke instanceof Character) {
|
else if (lastStroke instanceof char[]) {
|
||||||
processKey(editor, context, KeyStroke.getKeyStroke((Character)lastStroke));
|
final char[] chars = (char[])lastStroke;
|
||||||
|
for (char c : chars) {
|
||||||
|
processKey(editor, context, KeyStroke.getKeyStroke(c));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -542,10 +553,6 @@ public class ChangeGroup extends AbstractActionGroup {
|
|||||||
* @param context The data context
|
* @param context The data context
|
||||||
*/
|
*/
|
||||||
public void processEnter(@NotNull Editor editor, @NotNull DataContext context) {
|
public void processEnter(@NotNull Editor editor, @NotNull DataContext context) {
|
||||||
if (editor.isOneLineMode()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CommandState.getInstance(editor).getMode() == CommandState.Mode.REPLACE) {
|
if (CommandState.getInstance(editor).getMode() == CommandState.Mode.REPLACE) {
|
||||||
KeyHandler.executeAction("VimEditorToggleInsertState", context);
|
KeyHandler.executeAction("VimEditorToggleInsertState", context);
|
||||||
}
|
}
|
||||||
@@ -636,6 +643,7 @@ public class ChangeGroup extends AbstractActionGroup {
|
|||||||
*/
|
*/
|
||||||
private void clearStrokes(@NotNull Editor editor) {
|
private void clearStrokes(@NotNull Editor editor) {
|
||||||
strokes.clear();
|
strokes.clear();
|
||||||
|
repeatCharsCount = 0;
|
||||||
insertStart = editor.getCaretModel().getOffset();
|
insertStart = editor.getCaretModel().getOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1288,24 +1296,9 @@ public class ChangeGroup extends AbstractActionGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void indentLines(@NotNull Editor editor, @NotNull DataContext context, int lines, int dir) {
|
public void indentLines(@NotNull Editor editor, @NotNull DataContext context, int lines, int dir) {
|
||||||
int cnt = 1;
|
|
||||||
if (CommandState.inInsertMode(editor)) {
|
|
||||||
if (strokes.size() > 0) {
|
|
||||||
Object stroke = strokes.get(strokes.size() - 1);
|
|
||||||
if (stroke instanceof Character) {
|
|
||||||
Character key = (Character)stroke;
|
|
||||||
if (key == '0') {
|
|
||||||
deleteCharacter(editor, -1, false);
|
|
||||||
cnt = 99;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int start = editor.getCaretModel().getOffset();
|
int start = editor.getCaretModel().getOffset();
|
||||||
int end = CommandGroups.getInstance().getMotion().moveCaretToLineEndOffset(editor, lines - 1, false);
|
int end = CommandGroups.getInstance().getMotion().moveCaretToLineEndOffset(editor, lines - 1, false);
|
||||||
|
indentRange(editor, context, new TextRange(start, end), 1, dir);
|
||||||
indentRange(editor, context, new TextRange(start, end), cnt, dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void indentMotion(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @NotNull Argument argument, int dir) {
|
public void indentMotion(@NotNull Editor editor, @NotNull DataContext context, int count, int rawCount, @NotNull Argument argument, int dir) {
|
||||||
@@ -1620,6 +1613,7 @@ public class ChangeGroup extends AbstractActionGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final List<Object> strokes = new ArrayList<Object>();
|
private final List<Object> strokes = new ArrayList<Object>();
|
||||||
|
private int repeatCharsCount;
|
||||||
private List<Object> lastStrokes;
|
private List<Object> lastStrokes;
|
||||||
private int insertStart;
|
private int insertStart;
|
||||||
@Nullable private Command lastInsert;
|
@Nullable private Command lastInsert;
|
||||||
|
@@ -47,7 +47,6 @@ import com.maddyhome.idea.vim.ui.MorePanel;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@@ -122,17 +121,13 @@ public class MotionGroup extends AbstractActionGroup {
|
|||||||
private void addEditorListener(@NotNull Editor editor) {
|
private void addEditorListener(@NotNull Editor editor) {
|
||||||
editor.addEditorMouseListener(mouseHandler);
|
editor.addEditorMouseListener(mouseHandler);
|
||||||
editor.addEditorMouseMotionListener(mouseHandler);
|
editor.addEditorMouseMotionListener(mouseHandler);
|
||||||
|
|
||||||
editor.getSelectionModel().addSelectionListener(selectionHandler);
|
editor.getSelectionModel().addSelectionListener(selectionHandler);
|
||||||
editor.getScrollingModel().addVisibleAreaListener(scrollHandler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeEditorListener(@NotNull Editor editor) {
|
private void removeEditorListener(@NotNull Editor editor) {
|
||||||
editor.removeEditorMouseListener(mouseHandler);
|
editor.removeEditorMouseListener(mouseHandler);
|
||||||
editor.removeEditorMouseMotionListener(mouseHandler);
|
editor.removeEditorMouseMotionListener(mouseHandler);
|
||||||
|
|
||||||
editor.getSelectionModel().removeSelectionListener(selectionHandler);
|
editor.getSelectionModel().removeSelectionListener(selectionHandler);
|
||||||
editor.getScrollingModel().removeVisibleAreaListener(scrollHandler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1073,19 +1068,15 @@ public class MotionGroup extends AbstractActionGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean scrollLineToTopOfScreen(@NotNull Editor editor, int vline) {
|
private static boolean scrollLineToTopOfScreen(@NotNull Editor editor, int vline) {
|
||||||
EditorScrollHandler.ignoreChanges(true);
|
|
||||||
int pos = vline * editor.getLineHeight();
|
int pos = vline * editor.getLineHeight();
|
||||||
int vpos = editor.getScrollingModel().getVerticalScrollOffset();
|
int vpos = editor.getScrollingModel().getVerticalScrollOffset();
|
||||||
editor.getScrollingModel().scrollVertically(pos);
|
editor.getScrollingModel().scrollVertically(pos);
|
||||||
EditorScrollHandler.ignoreChanges(false);
|
|
||||||
|
|
||||||
return vpos != editor.getScrollingModel().getVerticalScrollOffset();
|
return vpos != editor.getScrollingModel().getVerticalScrollOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void scrollColumnToLeftOfScreen(@NotNull Editor editor, int vcol) {
|
private static void scrollColumnToLeftOfScreen(@NotNull Editor editor, int vcol) {
|
||||||
EditorScrollHandler.ignoreChanges(true);
|
|
||||||
editor.getScrollingModel().scrollHorizontally(vcol * EditorHelper.getColumnWidth(editor));
|
editor.getScrollingModel().scrollHorizontally(vcol * EditorHelper.getColumnWidth(editor));
|
||||||
EditorScrollHandler.ignoreChanges(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int moveCaretToMiddleColumn(@NotNull Editor editor) {
|
public int moveCaretToMiddleColumn(@NotNull Editor editor) {
|
||||||
@@ -1421,9 +1412,7 @@ public class MotionGroup extends AbstractActionGroup {
|
|||||||
updateSelection(editor, visualEnd);
|
updateSelection(editor, visualEnd);
|
||||||
|
|
||||||
editor.getCaretModel().moveToOffset(visualOffset);
|
editor.getCaretModel().moveToOffset(visualOffset);
|
||||||
//EditorData.setLastColumn(editor, editor.getCaretModel().getVisualPosition().column);
|
editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
|
||||||
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
|
||||||
//MotionGroup.moveCaret(editor, context, vr.getOffset());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1446,9 +1435,7 @@ public class MotionGroup extends AbstractActionGroup {
|
|||||||
updateSelection(editor, visualEnd);
|
updateSelection(editor, visualEnd);
|
||||||
|
|
||||||
editor.getCaretModel().moveToOffset(visualOffset);
|
editor.getCaretModel().moveToOffset(visualOffset);
|
||||||
//EditorData.setLastColumn(editor, editor.getCaretModel().getVisualPosition().column);
|
editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
|
||||||
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
|
||||||
//MotionGroup.moveCaret(editor, context, vr.getOffset());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1825,39 +1812,6 @@ public class MotionGroup extends AbstractActionGroup {
|
|||||||
private boolean makingChanges = false;
|
private boolean makingChanges = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class EditorScrollHandler implements VisibleAreaListener {
|
|
||||||
public static void ignoreChanges(boolean ignore) {
|
|
||||||
EditorScrollHandler.ignore = ignore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void visibleAreaChanged(@NotNull VisibleAreaEvent visibleAreaEvent) {
|
|
||||||
if (ignore) return;
|
|
||||||
|
|
||||||
Editor editor = visibleAreaEvent.getEditor();
|
|
||||||
if (CommandState.inInsertMode(editor)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug("old=" + visibleAreaEvent.getOldRectangle());
|
|
||||||
logger.debug("new=" + visibleAreaEvent.getNewRectangle());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!visibleAreaEvent.getNewRectangle().equals(visibleAreaEvent.getOldRectangle())) {
|
|
||||||
if (!EditorData.isConsoleOutput(editor) && !isTabSwitchEvent(visibleAreaEvent)) {
|
|
||||||
MotionGroup.moveCaretToView(editor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isTabSwitchEvent(@NotNull final VisibleAreaEvent visibleAreaEvent) {
|
|
||||||
final Rectangle newRectangle = visibleAreaEvent.getNewRectangle();
|
|
||||||
return newRectangle.width == 0 || newRectangle.height == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean ignore = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class EditorMouseHandler implements EditorMouseListener, EditorMouseMotionListener {
|
private static class EditorMouseHandler implements EditorMouseListener, EditorMouseMotionListener {
|
||||||
public void mouseMoved(EditorMouseEvent event) {
|
public void mouseMoved(EditorMouseEvent event) {
|
||||||
// no-op
|
// no-op
|
||||||
@@ -1934,7 +1888,6 @@ public class MotionGroup extends AbstractActionGroup {
|
|||||||
private int visualOffset;
|
private int visualOffset;
|
||||||
@NotNull private EditorMouseHandler mouseHandler = new EditorMouseHandler();
|
@NotNull private EditorMouseHandler mouseHandler = new EditorMouseHandler();
|
||||||
@NotNull private EditorSelectionHandler selectionHandler = new EditorSelectionHandler();
|
@NotNull private EditorSelectionHandler selectionHandler = new EditorSelectionHandler();
|
||||||
@NotNull private EditorScrollHandler scrollHandler = new EditorScrollHandler();
|
|
||||||
|
|
||||||
private static Logger logger = Logger.getInstance(MotionGroup.class.getName());
|
private static Logger logger = Logger.getInstance(MotionGroup.class.getName());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user