boolean (@NotNull KeyEvent keyPressed) { if (!isFeatureEnabled() || !isEnabledForProject()) { onShellCommandExecuted(); return false; } myLastKeyPressedMillis.set(System.currentTimeMillis()); String command = myWidget.getTypedShellCommand().trim(); if (LOG.isDebugEnabled()) { LOG.debug("typed shell command to execute: " + command); } myAlarm.cancelAllRequests(); Project project = myWidget.getProject(); String workingDirectory = getWorkingDirectory(); Executor executor = matchedExecutor(keyPressed); boolean hasRunningCommands; if (executor != null) { hasRunningCommands = hasRunningCommands(); } else { Boolean hasRunningCommandsLocal = myHasRunningCommands; if (hasRunningCommandsLocal == null) { // to not execute hasRunningCommands() on EDT just to report statistics onShellCommandExecuted(); return false; } hasRunningCommands = hasRunningCommandsLocal; } boolean localSession = !hasRunningCommands; if (!TerminalShellCommandHandler.Companion.matches(project, workingDirectory, localSession, command)) { onShellCommandExecuted(); return false; } TerminalShellCommandHandler handler = TerminalShellCommandHandler.Companion.getEP().getExtensionList().stream() .filter(it -> it.matches(project, workingDirectory, localSession, command)) .findFirst() .orElseThrow(() -> new RuntimeException("Cannot find matching command handler.")); if (executor == null) { onShellCommandExecuted(); TerminalUsageTriggerCollector.triggerSmartCommand(project, workingDirectory, localSession, command, handler, false); return false; } TerminalUsageTriggerCollector.triggerSmartCommand(project, workingDirectory, localSession, command, handler, true); TerminalShellCommandHandler.Companion.executeShellCommandHandler(myWidget.getProject(), getWorkingDirectory(), !hasRunningCommands(), command, executor); clearTypedCommand(command); return true; }