void (@NotNull PlaybackContext context, @NotNull ActionCallback actionCallback, @NotNull Editor editor, int offset) { final CaretListener caretListener = new CaretListener() { @Override public void caretPositionChanged(@NotNull CaretEvent e) { context.message(PerformanceTestingBundle.message("command.goto.finish"), getLine()); actionCallback.setDone(); } }; editor.getCaretModel().addCaretListener(caretListener); actionCallback.doWhenDone(() -> editor.getCaretModel().removeCaretListener(caretListener)); if (editor.getCaretModel().getOffset() == offset) { context.message(PerformanceTestingBundle.message("command.goto.finish"), getLine()); actionCallback.setDone(); } else { editor.getCaretModel().moveToOffset(offset); editor.getScrollingModel().scrollToCaret(ScrollType.CENTER); } }