Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Tracked by #2152
jakub-suliga opened this issue Jul 24, 2024 · 2 comments
Open
Tracked by #2152
Labels
bug Something isn't working

Comments

@jakub-suliga
Copy link

jakub-suliga commented Jul 24, 2024

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 jakub-suliga added the bug Something isn't working label Jul 24, 2024
@tomaswolf
Copy link
Member

Related to #2115 and #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...

@Christopher-Hermann
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants