void () { XmlTag tag = createTag("file.xhtml", "<a>xyz</a>"); PsiFile psiFile = tag.getContainingFile(); Document document = PsiDocumentManager.getInstance(psiFile.getProject()).getDocument(psiFile); RangeMarker rangeMarker = document.createRangeMarker(5, 5); final XmlText text = (XmlText) tag.getValue().getChildren()[0]; ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().executeCommand(getProject(), () -> { try{ text.removeText(2, 3); } catch(IncorrectOperationException ioe){} }, "", null, UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION)); assertEquals(5, rangeMarker.getStartOffset()); assertEquals(5, rangeMarker.getEndOffset()); }