-
Notifications
You must be signed in to change notification settings - Fork 186
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
Ensure lsp_save actually runs when context is active for keybinding #1852
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t understand how this solves the linked issue. Can you add some comments in code to explain why this is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like after detaching a document, the
on_query_context
in:LSP/plugin/documents.py
Line 408 in 0153663
returns
True
butLspTextCommand.is_enabled
:LSP/plugin/core/registry.py
Line 68 in 0153663
returns
False
.So it looks like those places check for sessions in a different way and one way is affected by the detach bug and the other isn't.
And it appears that
LspTextCommand.is_enabled
returningFalse
doesn't cause ST to ignore the keybinding.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DocumentSyncListener.on_query_context
returnsTrue
if a view is dragged to a new window, whileLspTextCommand.is_enabled
returnsFalse
. I don't know why this divergence happens, but there must be something fundamentally wrong with how applicable views are managed in a session or so. Probably due to the mentioned ST core issue thaton_post_move_async
isn't triggered. Anyway,on_query_context
will cause the keybinding to be active, whileis_enabled
prevents therun
method oflsp_save
to be executed. This turns Ctrl+S into "noop". By enforcingis_enabled
to beTrue
is it at least ensured that the command is run, and the file can be saved. The bug affected users even if they don't use any code actions on save at all.It should be pretty fine to have
is_enabled
always beTrue
, because it is only used for that keybinding and not in code viarun_command("lsp_save")
. In general, it should not make much sense to do the same check twice whether the keybinding is applicable or not, both inon_query_context
and inis_enabled
. Eventually a proper fix would ensure that both will return the same value forlsp_save
, so that the code actions on save also work as expected (not sure if they already work or not - I just wanted to fix the linked issue here).I don't really know if the actual bug is in
DocumentSyncListener.on_query_context
or inLspTextCommand.is_enabled
or somewhere else.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, this bug affects other things too. For example DocumentHighlights still seem to work fine, while most other things like hover won't work anymore with such a view.