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

Align "Expand Selection" fallback behavior with "Goto Definition" and "Find References" #2325

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

jwortmann
Copy link
Member

The "Expand Selection" command has a fallback argument, similar to "Goto Definition" and "Find References", which allows to invoke Sublime's built-in "Expand Selection" if there is no LSP result for the caret position or if the server doesn't have this capability. But for LSP's "Expand Selection" this fallback is enabled by default, while it is turned off for "Goto Definition" and "Find References". I did set the fallback to be enabled in #2124 to preserve former behavior of that functionality. But now I see no good reason why its fallback behavior should be different from the other commands, and I think it is confusing to see the context menu item for "Expand Selection" under the LSP submenu, even when there is no language server running at all (or if it doesn't have this capability), and also the main menu item not to be greyed out in that case. See also https://forum.sublimetext.com/t/is-there-a-tree-sitter-like-code-navigation-functionality-in-sublime/66442/6

I think it was originally enabled by default, because at the time of implementation there wasn't the lsp.session_with_capability "context" key for key bindings, if I understand the discussion in #1092 (comment) correctly. But now this shouldn't be needed anymore.

This PR changes the default value for "Expand Selection" to make the behaviors consistent, and so that the context menu item for this is not visible when there is no LSP running at all.

This could potentially still have an impact on existing key bindings, but only if there is a server which responds with no results for a given caret position while ST's built-in "Expand Selection" would still do something. But I'm not sure if this is really a realistic scenario. For servers without the capability it shouldn't make any difference, assuming the key binding was copied from the template including the "context" value.

Alternatively the fallback values of "Goto Definition" and "Find References" could be changed to be enabled by default.

Copy link
Member

@rwols rwols left a comment

Choose a reason for hiding this comment

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

I think it makes sense.

@rwols rwols merged commit 2f6142e into sublimelsp:main Sep 20, 2023
@jwortmann jwortmann deleted the expand-selection-fallback branch September 20, 2023 19:27
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.

2 participants