Allow settings to stick
Closed this issue ยท 8 comments
Issue raised by users on Marketplace: Allow settings to stick (persist) when opening new projects.
Users cite Lightbulb margin as one they want to stay OFF.
Yes please! That would make this extension perfect!
Currently the Lightbulb margin reappears when opening a new file.
One of your users posted this snippet (https://marketplace.visualstudio.com/items?itemName=JustinClareburtMSFT.HotSettings&ssr=false#qna):
[Export(typeof(IWpfTextViewCreationListener))]
[ContentType("text")]
[TextViewRole(PredefinedTextViewRoles.Document)]
internal class TestViewCreationListener : IWpfTextViewCreationListener
{
public void TextViewCreated(IWpfTextView textView)
{
textView.Options.SetOptionValue("TextViewHost/SuggestionMargin", false);
}
}
Thanks for bringing my attention to it.
Regarding the snippet above, I can't implement that into the base product because always defaulting to no lightbulb would not be the desired functionality for all users.
So, I would need to do what I suggested in a previous post, which is to store the setting in the user setting store and try to restore/set the value when a page is first loaded.
It's possible to store the user choices in the VS registry and check them at start-up, or on opening of every file. But I haven't coded that, yet.
By Justin Clareburt 4/12/2020
Design decision:
One major difference between the Lightbulb margin and the other margins that appear on the left editor margin is that the other options (Breakpoint, Line numbers, Selection) immediately act across all open files (as well as any new files opened).
But the Lightbulb margin currently only acts on the file in focus.
If that behaviour remains the same (ie. LB margin only affects the active editor), with a mix of editors that have and don't have the LB margin, there could be confusion from the user as to what the current default sticky settings is (ie. for new files and when files are reopened after restart). We would not be able to reflect that state on the context menu item. (Currently shows a tick/check if that specific editor has the LB margin enabled.) So we might need to find a place to surface the sticky state. We could add a button to a main toolbar like the editor toolbar or the Solution Explorer toolbar. Otherwise, it's not a big harm if the user doesn't know the sticky state in advance. They will find out as soon as a new editor opens, and changing the state of that editor will change the sticky state.
Another option is to change the behaviour of the LB margin to disable it on all editors. This might be harder to achieve, and more likely to result in bugs, but it would then be consistent with the other editor margin items. And it might be the behaviour that users expect/want/prefer. It would also eliminate the issue with not knowing or showing the sticky state of the LB margin.
So the big question is:....
Should toggling the lightbulb margin affect ALL open editors?
Edit:
I think the cleanest and most consistent solution would be for the LB margin setting to apply to all open editors, and remain sticky until changed. (ie. new editors and restored editors will have the most recent setting applied.)
Well I implemented the solution and it is released to the Visual Studio Marketplace as Hot Settings v1.6.0.
I went with the first option. I did not add any button.
I hope you like it!
Feel free to be say thanks by being a sponsor. ๐
https://github.com/sponsors/justcla
It works great. Thank you!
@justcla When I click the sponsor link it redirects me to your profile, and I'm unable to see a sponsor button.
It works great.
Excellent! I'm so glad. :-D
Thank you!
๐ Yay! You are most welcome. ๐
@justcla When I click the sponsor link it redirects me to your profile, and I'm unable to see a sponsor button.
Oh, I guess I haven't set it up completely. Thanks for trying anyway.
Your thanks is reward enough. ๐
@josephan Have you discovered Hot Status yet?
https://marketplace.visualstudio.com/items?itemName=JustinClareburtMSFT.HotStatus