void (@NotNull Editor editor) { CaretListener listener = new CaretListener() { @Override public void caretAdded(@NotNull CaretEvent e) { if (!isInteractiveModeSupported()) { finishTemplate(false); } } @Override public void caretRemoved(@NotNull CaretEvent e) { if (!isInteractiveModeSupported()) { finishTemplate(false); } } }; editor.getCaretModel().addCaretListener(listener, this); }