-
Notifications
You must be signed in to change notification settings - Fork 184
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
Fix LspToggleInlayHintsCommand not initializing #2571
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d0f7cd4
Fix LspToggleInlayHintsCommand not initializing
jwortmann 31b9dba
Simplify line
jwortmann bd076d5
Keep previous value when windows are restored on start
jwortmann 7f3da69
Read from settings file if available
jwortmann 1ede7f9
Rewording
jwortmann 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
Oops, something went wrong.
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.
Note that I put a literal
False
here ifuserprefs()
is None, because I assume that we cannot usesublime.load_settings('LSP.sublime-settings')
beforeplugin_loaded()
.This would only affect the very first window(s) which is/are open when Sublime Text starts.
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.
It's kinda not great to assume false when it might not be false.
Could we just not store anything on
init
and only do so when the command is run?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.
Yeah, actually that should work.
We could use
window_settings.get('lsp_show_inlay_hints', userprefs().show_inlay_hints)
inrun
and inis_checked
.Though this would be a behavior change in the way that when you change the value in the LSP settings, that change would also propagate to all windows where it hasn't been explicitly toggled yet. So I'm not sure if this is expected / the right thing to do.
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.
We could also delay reading the default and setting the window setting via using a
sublime.set_timeout
in__init__
.But I'm not sure if it is allowed to use
set_timeout
beforeplugin_loaded
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'm sure set_timeout is allowed but it doesn't sound very robust.
I don't feel like the case you've mentioned is something that we should need to avoid. It sounds fine to me to follow the global setting until explicitly changing the window setting.
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 think I would not quite like that, because it might appear very inconsistent to users. If you have multiple windows open and change the value in the settings, then it might be toggled in some of the windows but not in all. And since with my latest commit the window setting will be preserved when initializing, the manual toggle could have happened a long time ago and it would still have an effect here.
So I'd say the toggles should either be a global over all windows (I suggested that earlier when it was implemented, but we decided to not do this), or keep the current behavior and use the setting value only for newly created windows. The latter is also what is explained in the setting description:
LSP/LSP.sublime-settings
Lines 176 to 178 in 8b7afad