typescript.java
typescript.java copied to clipboard
Erroneous automatic folding
I'm noticing that while editing, some editing actions seem to trigger automatic folding.\
I've seen this happen for example when copy/pasting stuff, when using code completion to insert new stuff.
find it hard to pinpoint exactly what triggers it, but its a pita, as you're in the middle of making changes somewhere and all of a sudden the area where you are working is gone, because it is getting collapsed.
Anyone else noticing this? And is this something that most likely is caused by something in the TypeScript IDE codebase or maybe something in a superclass of the class used for the TypeScript Editor?
@p-bakker your problem is about indent folding? Could you add a demo with your problem please, thanks!
Its one of those things that is hard to reproduce, but does happen so once in a while.
I'll keep my eye out on a reproducible case
If problem is about folding, the strategy used is indentation. It's an Eclipse reconciler that I have developed.
It is about folding: got folding enabled and am working on a bit of code that is within several nested sections that could be folded, but are currently expanded (otherwise i could not be working on that bit of code :-) ).
Then, while editing the code, something happens due to which all of a sudden all the nested foldable levels collapse.
I'm yet to pinpoint what exactly it is that triggers this.
Knowing that this is part of your code, I'll post back here once I've nailed down how to reproduce this
ok, managed to make something reproducible, see test.txt (renamed to .txt as GitHub doesn't allow attaching .ts files)
Open this file in de TypeScript editor and then collapse all collapsible area's except for the path to line 80, like shown in startState.png

Then do the following:
- put the cursor after the semicolon on line 9,
- hit enter,
- hit backspace 4 times,
- type
case ''(!no trailing colon!!), - hit enter twice,
- hit tab,
- type
break
If all has gone according to the plan, you can now see the problem happening, The editor should now look like this:

If you now manually expand all required nodes so you can see line 80 again, you'll notice that some of the subnodes that you previously collapsed are expanded again (as well as the first if statement in the file).
If you now select the erroneous 3 new lines you just added and hit delete, you'll see you trigger the involuntary collapse again
Note that the described scenario above is not the only time this involuntary collapse happens, it's just one scenario I've managed to pinpoint so far.
BTW, noticed that the contextmenu that shows when rightclicking in the left gutter of the TypeScript Editor doesn't have a Folding entry, like on a Java Editor:

At least basic "collapse/expand all" would be handy, especially as you're enabled folding on such a granular level
Thanks a lot @p-bakker for your feedback. I must find time to study your problem, improve folding. I would like to support #region that TypeScript provides, just find time to do that:)
As I can understand that the involuntary collapse issue might be a difficult one, what about adding the collapse/expand functionality first, sort of as both just a handy feature and a 'workaround' for when the involuntary collapse happens? Being able to quickly expand everything when that happens would make the problem easier to deal with