tm4e icon indicating copy to clipboard operation
tm4e copied to clipboard

Code Folding

Open angelozerr opened this issue 8 years ago • 13 comments

TextMate grammar can define folding https://manual.macromates.com/en/navigation_overview

It should be cool if tm4e could provide the org.eclipse.tm4e.ui.folding.TMFoldingStrategy which supports this feature.

angelozerr avatar Mar 08 '17 22:03 angelozerr

Do you have an estimation of the ratio of textmate grammars that do enable folding? does VSCode rely on it ?

mickaelistria avatar Aug 07 '17 16:08 mickaelistria

Do you have an estimation of the ratio of textmate grammars that do enable folding? does VSCode rely on it ?

To be honnest with you, I don't remember. I must study again that but I'm very busy for the moment with JDT Codelens (an another project/topic).

angelozerr avatar Aug 07 '17 19:08 angelozerr

@micktaelistria the only thing that I can tell you is that VSCode uses by default the indent folding strategy that I have implemented for Eclipse https://github.com/angelozerr/typescript.java/blob/master/eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/ui/folding/IndentFoldingStrategy.java

Inside VSCode TypeScript, JSON, etc editor uses this folding strategy. I know you are working on folding feature for Generic Editor. IMHO, I think Generic Editor should use this indent folding strategy by default.

angelozerr avatar Aug 08 '17 08:08 angelozerr

I think Generic Editor should use this indent folding strategy by default.

I agree. Now that Generic Editor has an extension point for reconciler and an example about folding, it shouldn't be that hard to add it. Can you please open an enhancement request for that?

mickaelistria avatar Aug 08 '17 08:08 mickaelistria

Can you please open an enhancement request for that?

This bug exists https://bugs.eclipse.org/bugs/show_bug.cgi?id=512956

angelozerr avatar Aug 08 '17 08:08 angelozerr

This bug exists https://bugs.eclipse.org/bugs/show_bug.cgi?id=512956

That bug is about providing the extension-point, not about providing some (default) implementation.

mickaelistria avatar Aug 08 '17 08:08 mickaelistria

That bug is about providing the extension-point, not about providing some (default) implementation.

Done https://bugs.eclipse.org/bugs/show_bug.cgi?id=520659

angelozerr avatar Aug 08 '17 08:08 angelozerr

Was it implemented in tm4e? How can I use it in generic editor to fold/unfold yaml or json?

bartoszbinda avatar Jan 04 '19 13:01 bartoszbinda

Today tm4e doesn't support code folding, but I tell me if it's a good idea since LSP4E supports now folding. For instance json language server supports folding. For yaml, I don't know.

angelozerr avatar Jan 04 '19 18:01 angelozerr

What's the status of this?

norru avatar Jul 16 '19 10:07 norru

Still open, looking for volunteers to fix it. But as @angelozerr mentions, LSP4E now supports folding, so there is less value in using TM4E for that.

mickaelistria avatar Jul 16 '19 11:07 mickaelistria

It looks like some kind of folding now happens even without LSP, but it seems to be broken.

For toml only two sections are marked as foldable: image

For a cpp file the wrong lines are folded: screen

sebthom avatar May 12 '22 21:05 sebthom

Humm, no activity on folding support in the TM4E language configuration for a long while... would really like this but have way too little experience in Eclipse infrastructure to do it myself. It's a shame because the folding data is read from the language support file and shown in the UI - it just does not work (which is maybe worse than no support at all... spent a lot of time trying to get it to work before I found out it is actually not supported).

[Edit - updated to latest Eclipse version 2024.05 and I see there is a language config file for JSON and sure enough, when a .json file is opened with the Generic editor it has folding. But the Preferences->TextMate->LanguageConfiguration UI shows no folding start/end values defined for JSON... so how is folding working for JSON files? Oh, seems the generic editor has some default folding support for {...}. Any way to configure that for my language?]

cabintech avatar Dec 04 '24 14:12 cabintech