Excessive Unfolding

Answered

I am posting this despite having found other people complaining about a similar issue.

I have implemented a plugin for intellij to help me with a certain mangling scheme for identifiers.

Identifiers with extraneous characters, such as

core//{{Type}}[]-st

are represented in code by a mangled identifier, such as

core_$2f__$2f__$7b__$7b_Type_$7d__$7d__$5b__$5d__st

In order to see what's going on, these identifiers are kept folded via a plugin implementing the extension point

lang.foldingBuilder

The placeholder text is the unmangled identifier. (Another action is used to edit mangled identifiers)

This works swell, in all but one detail. Code gets unfolded much more often than it should. When I try to unfold a single identifier (by the "expand" action), every identifier gets unfolded! Pasted text gets unfolded... etc.

I have seen other people complain about excessive unfolding (e.g. https://intellij-support.jetbrains.com/hc/en-us/community/posts/206809345-Turning-off-Auto-code-unfolding?input_string=Folding%20%2F%20Unfolding%20of%20a%20single%20item), my question is:

Is there anything I can do as a plugin developer to prevent this?

1
4 comments

Many of the issues mentioned in the post, for which you've provided a link, are resolved in latest IDEA version, so the issues you see might be different.

> When I try to unfold a single identifier (by the "expand" action), every identifier gets unfolded! 

I'm not sure why you observe this behaviour. Are you sure you invoke 'expand' action, not 'expand all' or some other action? Could you provide more details about this issue?

> Pasted text gets unfolded.

Some more details could also help here.

0
Avatar
Permanently deleted user

Hi Dmitry, thank you for your time.

Here are two animations to illustrate what I mean.

I'm using Idea 2016.2 (community edition). I checked that the keybinding I was using is only doing cp;;extend, and not extend all (the bindings ctrl-numpad +/- are associated to both actions, by default! So I changed that to be sure)

Here all identifiers get unfolded when I activate the "Expand" action, and all of them get folded when I activate the "Collapse" action.

 I actually *would* like to be able to collapse all mangled identifiers. But only expand one at a time. I am guessing there is some way of having programmatic control over this.

Next is pasted text getting unfolded. If the text that is being pasted is itself folded, then nothing will unfold. If the pasted text is unfolded, then the mangled identifiers in the whole file will get unfolded.



Thank you,
Bruno


0

Hi Bruno,

Please check that you're not using the same FoldingGroup for all FoldingDescriptor instances generated by your folding builder. Fold regions created for such descriptors will always be collapsed or expanded together.

> I actually *would* like to be able to collapse all mangled identifiers. But only expand one at a time. I am guessing there is some way of having programmatic control over this.

There's no way to control it separately for collapsing and expanding (unless you create a specific action just for that). But probably marking your regions as 'collapsed by default' should be enough.

 

0
Avatar
Permanently deleted user

Beautiful! That was exactly the problem.

Sorry for such a noob mistake, and thank you again for your time!

0

Please sign in to leave a comment.