How to color code folds created via code?
Answered
Hi,
i have a custom editor and i want to added some code folds via
editor.getFoldingModel().createFoldRegion()
the question now is, how can i color these folds when they are collapsed? Right now they are colored like normal text.
Please sign in to leave a comment.
hi. The fold region colors are configured globally in settings|editor|Color scheme. THere's no way currently to color them individually.
Hi,
i have created a fold reagion, but this fold region is not colored in any way. I went into the settings and chose really bright colors, but its still not working:
If this helps, i added fold regions to the "DiffWindow" like this:
public class DiffWindowExtension extends DiffExtension {
@Override
public void onViewerCreated(FrameDiffTool.@NotNull DiffViewer viewer, @NotNull DiffContext context, @NotNull DiffRequest request) {
var left = ((SimpleDiffViewer) viewer).getEditor1();
var foldingModel = left.getFoldingModel();
foldingModel.runBatchFoldingOperation(() -> {
var foldRegion = foldingModel.createFoldRegion(
startOffset,
endOffset,
" ^--- THIS IS A PLACEHOLDER ---^ ",
FoldingGroup.newGroup(line + ""),
false
);
if (foldRegion != null) {
foldRegion.setExpanded(false);
foldRegion.setGutterMarkEnabledForSingleLine(true);
foldRegionList.add(foldRegion);
}
});
}
Do other folded regions in other files look blindingly red now?
I found the solution:
get the colorscheme, change it and then reapply it: