void () { initText("text"); getEditor().getSettings().setAdditionalLinesCount(0); getEditor().getSettings().setAdditionalColumnsCount(0); FoldingModel foldingModel = getEditor().getFoldingModel(); int[] size = new int[] {35, 25}; CustomFoldRegion[] region = new CustomFoldRegion[1]; foldingModel.runBatchFoldingOperation(() -> { region[0] = foldingModel.addCustomLinesFolding(0, 0, new CustomFoldRegionRenderer() { @Override public int calcWidthInPixels(@NotNull CustomFoldRegion region) { return size[0]; } @Override public int calcHeightInPixels(@NotNull CustomFoldRegion region) { return size[1]; } @Override public void paint(@NotNull CustomFoldRegion region, @NotNull Graphics2D g, @NotNull Rectangle2D targetRegion, @NotNull TextAttributes textAttributes) {} }); assertNotNull(region[0]); }); assertEquals(25, getEditor().visualLineToY(1)); assertEquals(new Dimension(35, 25), getEditor().getContentComponent().getPreferredSize()); size[0] = 36; size[1] = 26; region[0].update(); assertEquals(26, getEditor().visualLineToY(1)); assertEquals(new Dimension(36, 26), getEditor().getContentComponent().getPreferredSize()); }