Bug 520659 - [generic editor] Default Code folding for generic editor should use IndentFoldingStrategy
Summary: [generic editor] Default Code folding for generic editor should use IndentFol...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.7   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.9 M3   Edit
Assignee: Angelo ZERR CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on: 520685 521418
Blocks:
  Show dependency tree
 
Reported: 2017-08-08 04:56 EDT by Angelo ZERR CLA
Modified: 2018-08-04 03:36 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Angelo ZERR CLA 2017-08-08 04:56:06 EDT
Generic Editor should use indentation folding strategy by default (like VSCode).

I have developped a generic folding strategy (VSCode like) inside typescript.java which folds editor content by using indents at https://github.com/angelozerr/typescript.java/blob/master/eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/ui/folding/IndentFoldingStrategy.java

In my case, I have extended this class for TypeScript at https://github.com/angelozerr/typescript.java/blob/master/eclipse/jsdt/ts.eclipse.ide.jsdt.ui/src/ts/eclipse/ide/jsdt/internal/ui/editor/TypeScriptFoldingStrategy.java to fold content for "import" block.

Please note that my folding strategy works well but it should be improved perhaps because it folds the whole content of the editor every time you update a part of editor content. But performance are very good without this optimization.

If you are interested, I could do a PR with my IndentFoldingStrategy. Tell me if you are interested and where I could host this class (in which packages).
Comment 1 Mickael Istria CLA 2017-08-08 05:00:58 EDT
Hey Angelo! We'd be for sure interested in a patch providing this reconciler directly in the generic editor bundle, and making it used by default when no other one is available.
Comment 2 Angelo ZERR CLA 2017-08-08 05:55:01 EDT
> Hey Angelo! We'd be for sure interested in a patch providing this reconciler directly in the generic editor bundle

Cool!

> and making it used by default when no other one is available.

You mean bind reconciler with "org.eclipse.core.runtime.text"? In other words declare the reconciler extension point in the genericeditor plugin.xml :

-----------------------------
<extension
 point="org.eclipse.ui.genericeditor.reconcilers">
 <reconciler					   
  class="org.eclipse.ui.internal.genericeditor.folding.DefaultFoldingReconciler"					
  contentType="org.eclipse.core.runtime.text">
 </reconciler>
</extension>
-----------------------------

If I do that, folding will be done every time. Do you want that? Perhaps in the future we should have a preferences to disable folding for a given content type?

It's an another topic, but I tell me if genericeditor should improve reconciler extension point to register a list of IReconcilerStrategy for a given reconciler (one reconciler for a list of IReconcilerStrategy) to avoid having just one Thread to extecute list of IReconcilerStrategy  (spelling, folding, etc) and not have one thread (one reconciler per IReconcilerStrategy)
Comment 3 Mickael Istria CLA 2017-08-08 07:30:18 EDT
> You mean bind reconciler with "org.eclipse.core.runtime.text"? In other
> words declare the reconciler extension point in the genericeditor plugin.xml

Right, maybe we should add the after/before pattern that's implemented on hover, and make this one after=*

> It's an another topic, but I tell me if genericeditor should improve
> reconciler extension point to register a list of IReconcilerStrategy for a
> given reconciler (one reconciler for a list of IReconcilerStrategy) to avoid
> having just one Thread to extecute list of IReconcilerStrategy  (spelling,
> folding, etc) and not have one thread (one reconciler per
> IReconcilerStrategy)

Sure, please open a separate bug for this specific issue.
Comment 4 Eclipse Genie CLA 2017-08-08 08:16:12 EDT
New Gerrit change created: https://git.eclipse.org/r/102673
Comment 5 Angelo ZERR CLA 2017-08-08 08:45:06 EDT
> Right, maybe we should add the after/before pattern that's implemented on hover, and make this one after=*

Perhaps you could do that yourself after accepting my PR?

> Sure, please open a separate bug for this specific issue.
Done with https://bugs.eclipse.org/bugs/show_bug.cgi?id=520686
Comment 6 Mickael Istria CLA 2017-08-08 08:48:50 EDT
(In reply to Angelo ZERR from comment #5)
> Perhaps you could do that yourself after accepting my PR?

I believe bug 520659 would be a better heuristic. 

> https://bugs.eclipse.org/bugs/show_bug.cgi?id=520686

Thanks.
Comment 7 Mickael Istria CLA 2017-08-08 12:07:24 EDT
(In reply to Mickael Istria from comment #6)
> I believe bug 520659 would be a better heuristic. 

Sorry, I meant bug 520685. Once we have it, it would make the default indent work for all text, unless another one is associated to a more specific type.
I believe it's a great way to enable "default".
Comment 8 Angelo ZERR CLA 2017-09-01 07:13:24 EDT
@Mickael, @Lucas, please review my new PR at https://git.eclipse.org/r/#/c/102673/ 

Thanks!
Comment 9 Dani Megert CLA 2018-05-24 12:52:34 EDT
Removing target milestone for all bugs that are not major or above.
Comment 10 Dani Megert CLA 2018-05-25 04:05:40 EDT
> Removing target milestone for all bugs that are not major or above.

Of course I meant "major or below".

Sorry for the noise!
Comment 11 Eclipse Genie CLA 2018-08-01 11:35:58 EDT
New Gerrit change created: https://git.eclipse.org/r/126902
Comment 12 Angelo ZERR CLA 2018-08-01 11:40:05 EDT
@Mickael, @Lucas please review my new gerrit patch https://git.eclipse.org/r/#/c/126902/ which:

 * defines a new extension point foldingReconciler (like higlightreconciler)
 * uses the indent folding strategy as default (same behaviour than default word highlight)
 * add test with indent folding strategy.

I tell mee too if we could have too a Toogle button to enable/disable folding. We have that for highlight, so why we cannot do that for folding?
Comment 13 Angelo ZERR CLA 2018-08-02 13:11:14 EDT
@Mickael, @lucas what do you think about "I tell mee too if we could have too a Toogle button to enable/disable folding. We have that for highlight, so why we cannot do that for folding?"?
Comment 14 Eclipse Genie CLA 2018-08-02 13:13:16 EDT
New Gerrit change created: https://git.eclipse.org/r/126991
Comment 15 Angelo ZERR CLA 2018-08-02 13:14:11 EDT
@Mickael, @lucas, once you will merge my work about folding, please review the N&N at https://git.eclipse.org/r/#/c/126991/ Thanks!
Comment 16 Lucas Bullen CLA 2018-08-02 13:15:12 EDT
(In reply to Angelo ZERR from comment #13)
> @Mickael, @lucas what do you think about "I tell mee too if we could have
> too a Toogle button to enable/disable folding. We have that for highlight,
> so why we cannot do that for folding?"?

I don't see a real need to toggle folding. It can just be ignored. Unlike highlighting which is visible in the editor and could distract a user, folding is off to the side and up to the user to use if wanted
Comment 17 Angelo ZERR CLA 2018-08-02 13:23:40 EDT
> I don't see a real need to toggle folding. It can just be ignored. Unlike highlighting which is visible in the editor and could distract a user, folding is off to the side and up to the user to use if wanted

Thanks for your answer @Lucas. I have updated my gerrit patch to remove this information from the description of foldingReconcilers.exsd
Comment 19 Eclipse Genie CLA 2018-08-04 02:53:32 EDT
New Gerrit change created: https://git.eclipse.org/r/127055