eclipse-jdt / eclipse.jdt.ui

Eclipse Public License 2.0
36 stars 86 forks source link

[23] Folding a markdown region hides the first line of subsequent Java code #1615

Open stephan-herrmann opened 2 weeks ago

stephan-herrmann commented 2 weeks ago

Given

    ///
    /// This is the comment of m()
    ///
    void m() {
        System.out.println("m");
    }

when you fold the markdown comment in the editor, it looks like this:

image

@jarthana looks like your latest change in #1549 only moved the problem :)

stephan-herrmann commented 6 days ago

@jarthana have you seen this?

jarthana commented 4 days ago

@jarthana have you seen this?

Thanks, will take a look.

jarthana commented 4 days ago

Actually, I don't see fold/unfold option at all for markdown comments. Sigh! Let me see what's going on.

jarthana commented 4 days ago

Actually, I don't see fold/unfold option at all for markdown comments. Sigh! Let me see what's going on.

This turned out to be the result of making the feature standard feature. Without that patch, the markdown folds/unfolds well.

Anyway, I am unable to see the problem. @stephan-herrmann Can you please check now?

stephan-herrmann commented 3 days ago

This turned out to be the result of making the feature standard feature. Without that patch, the markdown folds/unfolds well.

Wow, for preview features, isSupported() only checks that flag, ignoring the compliance / source levels. As a standard feature we check compliance, but org.eclipse.jdt.ui.text.folding.DefaultJavaFoldingStructureProvider.fSharedScanner uses JavaCore's default compliance level, ignoring what might be configured per project.

Sharing a scanner seems to be incompatible with version-dependent scanning :-(

stephan-herrmann commented 3 days ago

Anyway, I am unable to see the problem. @stephan-herrmann Can you please check now?

When setting the workspace default compliance to 23 I can still see the same problem as before.

@jarthana Here's the difference: I normally use unix line-ends. When I change this to windows line-ends, folding is correct. Conversely, you should be able to see the bug when switching to unix line-ends.

Does this help to find some off-by-one bug?

jarthana commented 2 days ago

Wow, for preview features, isSupported() only checks that flag, ignoring the compliance / source levels. As a standard feature we check compliance, but org.eclipse.jdt.ui.text.folding.DefaultJavaFoldingStructureProvider.fSharedScanner uses JavaCore's default compliance level, ignoring what might be configured per project.

Yeah, that is written based on the assumption that preview can only be enabled when the compliance is the highest. That works within the compiler but as it turns out, not all clients follow that rule.

jarthana commented 2 days ago

Anyway, I am unable to see the problem. @stephan-herrmann Can you please check now?

When setting the workspace default compliance to 23 I can still see the same problem as before.

@jarthana Here's the difference: I normally use unix line-ends. When I change this to windows line-ends, folding is correct. Conversely, you should be able to see the bug when switching to unix line-ends.

Does this help to find some off-by-one bug?

Reproduced. Thanks for the tip!