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

Support for textDocument/selectionRange #562

Merged
merged 1 commit into from
Mar 22, 2023

Conversation

angelozerr
Copy link
Contributor

Support for textDocument/selectionRange

Fixes #561

@angelozerr
Copy link
Contributor Author

angelozerr commented Mar 20, 2023

This PR provides standard shortcut ALT+SHIFT+UP / ALT+SHIFT+DOWN to manage selection range like WTP.

For XML, you will need the PR eclipse/lemminx#1507

You can test this PR with HTML language server for instance:

HTMLSelectionRange

or with CSS language server:

CSSSelectionRange

if (document != null) {
LanguageServerDocumentExecutor executor = LanguageServers.forDocument(document)
.withCapability(ServerCapabilities::getSelectionRangeProvider);
if (executor.anyMatching()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should the executor.anyMatching condition not go inside if on the condition handler.isDirty? The else branch does not use the language server, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did that because I wanted to avoid storing in Styledtext the SelectionRangeHandler instance if there are no LS which supports SelectionRange but I can change that if you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure I understand that, so I do not know if it is better to change it or, but at least we should add a comment why it is like it is at the moment, I think it is not something one can figure out from the code. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When user does several Alt+Sift+UP, Alt+Sift+DOWN, there is just one consume of the textDocument/SelectionRange (the first call of Alt+Sift+UP or Alt+Sift+DOWN. After that the result is cached on an instance of SelectionRangeHandler. When user change the cursor location, SelectionRangeHandler is removed. This instance is stored in the Styledtext (I consider that is an instance of the editor).

BUT if there are no language server which support textDocument/SelectionRange, there is no sense to store an instance of SelectionRangeHandler in a Styledtext.

Do you understand what I mean?

Copy link
Contributor Author

@angelozerr angelozerr Mar 20, 2023

Choose a reason for hiding this comment

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

@rubenporras I tried to add some comments, please tell me if it better and more understandable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it is a bit better now. I understand what you mean in your last post.

BTW: Do you think it would be possible to have some test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fear that I will not have time to do that now -(

org.eclipse.lsp4e/plugin.xml Outdated Show resolved Hide resolved
org.eclipse.lsp4e/plugin.xml Outdated Show resolved Hide resolved
@rubenporras
Copy link
Contributor

apart from missing tests, it looks good to me, but I cannot invest much time to actually review it properly, maybe @mickaelistria could do the final review?

@mickaelistria
Copy link
Contributor

@mickaelistria could do the final review?

As it's all internal and given we already both shared our main concerns and those got covered; I would be for just merging and improve later if need be.

@mickaelistria mickaelistria merged commit 0eb29b1 into eclipse:master Mar 22, 2023
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.

Support for textDocument/selectionRange
3 participants