Multiline folding/virtual text

Hey devs,
I've made a plugin called inheritDoc helper for php that basically replaces the tag "@inheritDoc" in comments with the comments block of the parent class.
In order to do that I used folding. However folding does not allow the injected text to contain multiple lines so I have to collapse everything in one line in order to show something.

Ideally I want to replace the text with multiple lines but on click/select it would still collapse and show the original text "@inheritDoc" like the original folding feature.

Does anyone have an idea how to accomplish this?

3 comments
Comment actions Permalink

> folding does not allow the injected text to contain multiple lines

Thanos, you can adjust folded region to include multiple lines. You can also group folded regions.

experiment with this FoldingDescriptor constructor:

public FoldingDescriptor(@NotNull ASTNode node, @NotNull TextRange range, @Nullable FoldingGroup group);

0
Comment actions Permalink

Hmm are you sure? I am talking about the resulting "placeholder" text (after the fold) containing multiple lines.
I want the folded regions to contain multiple lines. In fact potentially more lines than the original unfolded text.
Testing it results in newlines being stripped.

0
Comment actions Permalink

I misunderstood. I was writing about the original text which is folded.

Usually the folded region description is only a short one, a one-liner.

As a workaround you could break the original text into parts (I mean, pass incomplete TextRange to FoldingDescriptor ctor) and fold each part without grouping them. It should work if there are enough newlines in the original text.

0

Please sign in to leave a comment.