mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-07-29 16:59:01 +02:00
Make actions loading async
This commit is contained in:
parent
44e224489b
commit
59bcd24c47
src/com/maddyhome/idea/vim
@ -36,22 +36,8 @@ public class RegisterActions {
|
||||
* Register all the key/action mappings for the plugin.
|
||||
*/
|
||||
static void registerActions() {
|
||||
Runnable setup = () -> {
|
||||
registerVimCommandActions();
|
||||
registerEmptyShortcuts();
|
||||
VimPlugin.Initialization.actionsInitialized();
|
||||
};
|
||||
|
||||
// Temporally remove async initialization
|
||||
setup.run();
|
||||
/*
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
setup.run();
|
||||
}
|
||||
else {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(setup);
|
||||
}
|
||||
*/
|
||||
registerVimCommandActions();
|
||||
registerEmptyShortcuts();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -305,21 +305,31 @@ public class VimPlugin implements BaseComponent, PersistentStateComponent<Elemen
|
||||
getSearch().turnOn();
|
||||
VimListenerManager.INSTANCE.turnOn();
|
||||
|
||||
// Register vim actions in command mode
|
||||
RegisterActions.registerActions();
|
||||
|
||||
// Add some listeners so we can handle special events
|
||||
DocumentManager.getInstance().addDocumentListener(MarkGroup.MarkUpdater.INSTANCE);
|
||||
DocumentManager.getInstance().addDocumentListener(SearchGroup.DocumentSearchListener.INSTANCE);
|
||||
|
||||
// Register ex handlers
|
||||
CommandParser.getInstance().registerHandlers();
|
||||
Runnable asyncSetup = () -> {
|
||||
// Register vim actions in command mode
|
||||
RegisterActions.registerActions();
|
||||
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
final File ideaVimRc = VimScriptParser.findIdeaVimRc();
|
||||
if (ideaVimRc != null) {
|
||||
VimScriptParser.executeFile(ideaVimRc);
|
||||
// Register ex handlers
|
||||
CommandParser.getInstance().registerHandlers();
|
||||
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
final File ideaVimRc = VimScriptParser.findIdeaVimRc();
|
||||
if (ideaVimRc != null) {
|
||||
VimScriptParser.executeFile(ideaVimRc);
|
||||
}
|
||||
}
|
||||
|
||||
Initialization.initialized();
|
||||
};
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
asyncSetup.run();
|
||||
} else {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(asyncSetup);
|
||||
}
|
||||
}
|
||||
|
||||
@ -403,20 +413,14 @@ public class VimPlugin implements BaseComponent, PersistentStateComponent<Elemen
|
||||
}
|
||||
|
||||
public static class Initialization {
|
||||
private static final AtomicBoolean initializedActions = new AtomicBoolean(false);
|
||||
private static final AtomicBoolean initializedCommands = new AtomicBoolean(false);
|
||||
private static final AtomicBoolean initialized = new AtomicBoolean(false);
|
||||
|
||||
public static boolean notInitialized() {
|
||||
return !(initializedActions.get() &&
|
||||
initializedCommands.get());
|
||||
return !(initialized.get());
|
||||
}
|
||||
|
||||
public static void actionsInitialized() {
|
||||
initializedActions.set(true);
|
||||
}
|
||||
|
||||
public static void commandsInitialized() {
|
||||
initializedCommands.set(true);
|
||||
public static void initialized() {
|
||||
initialized.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,23 +73,9 @@ public class CommandParser {
|
||||
public void registerHandlers() {
|
||||
if (registered.getAndSet(true)) return;
|
||||
|
||||
Runnable setup = () -> {
|
||||
for (CommandHandler handler : EX_COMMAND_EP.getExtensions()) {
|
||||
handler.register();
|
||||
}
|
||||
|
||||
VimPlugin.Initialization.commandsInitialized();
|
||||
};
|
||||
|
||||
// Temporally remove async initialization
|
||||
setup.run();
|
||||
/*
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
setup.run();
|
||||
} else {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(setup);
|
||||
for (CommandHandler handler : EX_COMMAND_EP.getExtensions()) {
|
||||
handler.register();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user