void () { final DocumentEx document = (DocumentEx) getFirstEditor().getDocument(); ApplicationManager.getApplication().runWriteAction(() -> document.setText("line1\nline2")); int start = document.getLineStartOffset(1); int end = document.getLineEndOffset(1); RangeMarker rangeMarker = document.createRangeMarker(start, end); moveCaret(getFirstEditor(), DOWN, false); executeEditorAction(getFirstEditor(), IdeActions.ACTION_MOVE_LINE_UP_ACTION); undoFirstEditor(); assertEquals(new TextRange(start, end), rangeMarker.getTextRange()); }