void () { doTest(() -> { final Editor editor = myFixture.getEditor(); final Document document = editor.getDocument(); final int selectionStart = editor.getSelectionModel().getSelectionStart(); final int selectionEnd = editor.getSelectionModel().getSelectionEnd(); WriteCommandAction.runWriteCommandAction(getProject(), () -> document.deleteString(selectionStart, selectionEnd)); editor.getCaretModel().moveToOffset(selectionStart); }); }