void () { // We had a problem that caret preserved its visual position instead of offset. This test checks that. String text = """ /** * This is a test comment */ public class Test { }"""; init(100, text); addCollapsedFoldRegion(0, text.indexOf("public") - 1, "/**...*/"); int offset = text.indexOf("class"); CaretModel caretModel = getEditor().getCaretModel(); caretModel.moveToOffset(offset); assertEquals(offset, caretModel.getOffset()); assertEquals(1, caretModel.getVisualPosition().line); toggleFoldRegionState(getFoldRegion(0), true); assertEquals(3, caretModel.getVisualPosition().line); assertEquals(offset, caretModel.getOffset()); }