void () { String text = """ this is line number 0 this is line number 1 this is line number 2 this is line number 3 this is line number 4 this is line number 5 this is line number 6 this is the last line"""; init(100, text); int lineToSelect = 4; getEditor().getCaretModel().moveToOffset(text.indexOf("number " + lineToSelect)); Document document = getEditor().getDocument(); int startOffset = document.getLineStartOffset(lineToSelect); int endOffset = document.getLineEndOffset(lineToSelect); getEditor().getSelectionModel().setSelection(startOffset, endOffset); VisualPosition positionBefore = getEditor().offsetToVisualPosition(document.getLineStartOffset(lineToSelect + 1)); List<SoftWrap> softWrapsBefore = new ArrayList<>(getSoftWrapModel().getRegisteredSoftWraps()); copy(); paste(); assertEquals(positionBefore, getEditor().offsetToVisualPosition(document.getLineStartOffset(lineToSelect + 1))); assertEquals(softWrapsBefore, getSoftWrapModel().getRegisteredSoftWraps()); }