void () { String text = """ short line this is a long line that is expected to be soft wrapped into more than one or even two visual lines 1. just a line that is long enough to be soft wrapped 2. just a line that is long enough to be soft wrapped 3. just a line that is long enough to be soft wrapped 4. just a line that is long enough to be soft wrapped"""; init(15, text); Document document = getEditor().getDocument(); int start = document.getLineStartOffset(1); int end = document.getLineEndOffset(1) + 1; int visualLinesToRemove = getSoftWrapModel().getSoftWrapsForLine(1).size() + 1; List<VisualPosition> positionsBefore = new ArrayList<>(); for (int i = end; i < text.length(); i++) { positionsBefore.add(getEditor().offsetToVisualPosition(i)); } Collections.reverse(positionsBefore); getEditor().getSelectionModel().setSelection(start, end); delete(); // Check that all remembered positions are just shifted to expected number of visual lines. for (int i = start; i < document.getTextLength(); i++) { VisualPosition position = positionsBefore.remove(positionsBefore.size() - 1); assertEquals(new VisualPosition(position.line - visualLinesToRemove, position.column), getEditor().offsetToVisualPosition(i)); } }