Skip to content
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

feat: support initial folding of license header #1184

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

sebthom
Copy link
Member

@sebthom sebthom commented Jan 15, 2025

This PR addresses #884 by adding a new folding option to automatically fold license headers on initial opening of an editor.

image

If the first foldable comment of a file a license header is determined using a regex (?i)(copyright|licensed under|all rights reserved|SPDX-License-Identifier)

The behaviour is different to Eclipse JDT which has an option to generally fold all header comments:
image

@sebthom sebthom requested a review from mickaelistria January 15, 2025 14:51
@@ -63,6 +64,9 @@ public class LSPFoldingReconcilingStrategy

private static final Annotation[] NO_ANNOTATIONS = new Annotation[0];

private static final Pattern LICENSE_KEYWORDS = Pattern
.compile("(?i)(copyright|licensed under|all rights reserved|SPDX-License-Identifier)"); //$NON-NLS-1$
Copy link
Contributor

@rubenporras rubenporras Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this kind of folding not something that should be determined by de server, which can know more about the structure of the language?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, probably, but the LSP does specify such information at the moment; so we cannot use anything like it so far.

Copy link
Member Author

@sebthom sebthom Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was discussed/rejected here microsoft/language-server-protocol#1819

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@sebthom sebthom merged commit a096dad into eclipse-lsp4e:main Jan 15, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants