Promise<Object> (@NotNull PlaybackContext context) { ActionCallback actionCallback = new ActionCallbackProfilerStopper(); String input = extractCommandArgument(PREFIX); String[] lineAndColumn = input.split(" "); final int startLine = Integer.parseInt(lineAndColumn[0]) - 1; final int startColumn = Integer.parseInt(lineAndColumn[1]) - 1; final int endLine = Integer.parseInt(lineAndColumn[2]) - 1; final int endColumn = Integer.parseInt(lineAndColumn[3]) - 1; ApplicationManager.getApplication().executeOnPooledThread(() -> { try { Waiter.checkCondition(() -> findTarget(context) != null).await(10, TimeUnit.MINUTES); } catch (InterruptedException e) { actionCallback.reject(e.getMessage()); return; } ApplicationManager.getApplication().invokeAndWait(() -> { TypingTarget target = findTarget(context); if (target instanceof EditorComponentImpl) { EditorImpl editor = ((EditorComponentImpl)target).getEditor(); Document document = editor.getDocument(); editor.getSelectionModel() .setSelection(document.getLineStartOffset(startLine) + startColumn, document.getLineStartOffset(endLine) + endColumn); actionCallback.setDone(); } else { actionCallback.reject("Cannot replace text on non-Editor component"); } }); }); return Promises.toPromise(actionCallback); }