Skip to content

Commit

Permalink
Activate INS mode when invoking search everywhere and run anything (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
amibiz authored Jul 18, 2020
1 parent b17745e commit b98e236
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ intellij {
}

patchPluginXml {
sinceBuild '183'
sinceBuild '183.3'
untilBuild '201.*'
}
30 changes: 26 additions & 4 deletions src/main/java/com/github/amibiz/ergokeys/ErgoKeysPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

package com.github.amibiz.ergokeys;

import com.intellij.ide.actions.SearchEverywhereAction;
import com.intellij.ide.actions.runAnything.RunAnythingAction;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Shortcut;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.AnActionListener;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ApplicationComponent;
Expand Down Expand Up @@ -139,6 +139,28 @@ public void activeKeymapChanged(@Nullable Keymap keymap) {
}
});

ApplicationManager.getApplication().getMessageBus().connect().subscribe(AnActionListener.TOPIC, new AnActionListener() {
@Override
public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
LOG.debug("beforeActionPerformed: action.class=", action.getClass());

if (action.getClass().equals(SearchEverywhereAction.class) ||
action.getClass().equals(RunAnythingAction.class)) {
final Editor editor = dataContext.getData(CommonDataKeys.EDITOR);
activateInsertMode(editor);
}
}

@Override
public void afterActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {
LOG.debug("afterActionPerformed: action.class=", action.getClass());
}

@Override
public void beforeEditorTyping(char c, @NotNull DataContext dataContext) {
LOG.debug("beforeEditorTyping: c=", c);
}
});

EditorFactory.getInstance().addEditorFactoryListener(
new EditorFactoryListener() {
Expand Down

0 comments on commit b98e236

Please sign in to comment.