in core/src/com/jediterm/core/typeahead/TerminalTypeAheadManager.java [88:132]
public void onKeyEvent(@NotNull TypeAheadEvent keyEvent) {
if (!myTerminalModel.isTypeAheadEnabled()) return;
myTerminalModel.lock();
try {
if (myTerminalModel.isUsingAlternateBuffer()) {
resetState();
return;
}
TypeAheadTerminalModel.LineWithCursorX lineWithCursorX = myTerminalModel.getCurrentLineWithCursor();
long prevTypedTime = myLastTypedTime;
myLastTypedTime = System.nanoTime();
long autoSyncDelay;
if (myLatencyStatistics.getSampleSize() >= LATENCY_MIN_SAMPLES_TO_TURN_ON) {
autoSyncDelay = Math.min(myLatencyStatistics.getMaxLatency(), MAX_TERMINAL_DELAY);
} else {
autoSyncDelay = MAX_TERMINAL_DELAY;
}
boolean hasTypedRecently = System.nanoTime() - prevTypedTime < autoSyncDelay;
if (hasTypedRecently) {
if (myOutOfSyncDetected) {
return;
}
} else {
myOutOfSyncDetected = false;
}
reevaluatePredictorState(hasTypedRecently);
updateLeftMostCursorPosition(lineWithCursorX.myCursorX);
if (myPredictions.isEmpty() && myClearPredictionsDebouncer != null) {
myClearPredictionsDebouncer.call(); // start a timer that will clear predictions
}
TypeAheadPrediction prediction = createPrediction(lineWithCursorX, keyEvent);
myPredictions.add(prediction);
applyPredictions();
LOG.debug("Created " + keyEvent.myEventType + " prediction");
} finally {
myTerminalModel.unlock();
}
}