eclipse.platform.ui icon indicating copy to clipboard operation
eclipse.platform.ui copied to clipboard

[Sticky scrolling] Commented-out code is being incorrectly recognized

Open jakub-suliga opened this issue 1 year ago • 2 comments

When code is commented out, sticky scrolling incorrectly detects the line.

To reproduce this issue: Under org.eclipse.jdt.ui.text.folding.DefaultJavaFoldingStructureProvider.CommentPosition.findFirstContent(CharSequence, int), some code is commented out.

image

In the method org.eclipse.jdt.ui.text.folding.DefaultJavaFoldingStructureProvider.CommentPosition.computeProjectionRegions(IDocument), there is some commented-out code. Before the the commented out line:

image

And after:

image

jakub-suliga avatar Jul 24 '24 08:07 jakub-suliga

Related to https://github.com/eclipse-platform/eclipse.platform.ui/issues/2115 and https://github.com/eclipse-platform/eclipse.platform.ui/issues/1950 . Sticky scrolling would need to be able to know what a comment is, which is different in different languages. AFAIK the current implementation is based purely on indentation?

Perhaps it could consider document partitions, if any. Though I'm not sure there is any platform-wide "standard" to identify comment partitions, and not every editor might use partitions for comments...

tomaswolf avatar Jul 24 '24 09:07 tomaswolf

Correct, sticky scrolling is based purely on indentation. It is planned to provide a extension point so that every language can define a own implementation for the sticky scrolling calculation. For java we can then provide a implementation that is able to handle this kind of comments, annotations which are currently a problem or unusual code styles. If no specific implementation is provided, the default will still be based on indentation.

Unfortunately I had no time to look into this yet, but definitely want to pick this one up as soon as I have some time.

Christopher-Hermann avatar Aug 02 '24 06:08 Christopher-Hermann

Fixed with #2756 and https://github.com/eclipse-jdt/eclipse.jdt.ui/pull/2149

Christopher-Hermann avatar Oct 20 '25 05:10 Christopher-Hermann