void () { typeInText(getFirstEditor(), "a\nb\nc\nd\ne\nf"); typeInText(getSecondEditor(), "a\nb\nc\nd\ne\nf"); WriteCommandAction.runWriteCommandAction(myProject, () -> { getFirstEditor().getDocument().insertString(0, " "); getSecondEditor().getDocument().insertString(0, " "); }); selectSecondEditor(); moveCaret(getSecondEditor(), UP, false); undo(getSecondEditor()); checkEditorText("a\nb\nc\nd\ne\nf", getSecondEditor()); assertEquals(9, getSecondEditor().getCaretModel().getOffset()); }