tunnelvisionlabs / JustMyCodeToggle

Adds the Just My Code command button to Visual Studio
https://marketplace.visualstudio.com/items?itemName=SamHarwell.JustMyCodeToggle
MIT License
12 stars 7 forks source link

Toolbar button is initially incorrect #13

Closed jnm2 closed 6 years ago

jnm2 commented 6 years ago

Opened VS, started debugging, opened options without changing anything:

image

After clicking, the icon stays untoggled (because it toggled, like it is supposed to).

I think this is what was behind https://github.com/tunnelvisionlabs/JustMyCodeToggle/issues/12. I don't know why I worked around this so long without reporting it—keyboard shortcut makes life easy, I guess! 😄

jnm2 commented 6 years ago

I debugged the extension and it's immediately obvious that this is due to the package not initializing until the command is activated. @sharwell This still catches me and I've seen it catch a coworker recently. I'd love to make it autoload. What do you think?

jcansdale commented 6 years ago

Auto loading packages are evil. It's just too tempting to create them. 😉

This is actually why I thought a Start Debugging Just My Code command might be a good idea. This wouldn't have a dependency on the initial state of the Just My Code option.

jnm2 commented 6 years ago

At the end of the day, I like looking at the button to see if it's on.

jcansdale commented 6 years ago

Alternatively, we could have two JustMyCodeToggle related commands, EnableJustMyCode and DisableJustMyCode. Their initial visibility would be determined by a UserSettingsStoreQuery that looks at the users settings to to see if JustMyCode is enabled or not.

See: https://docs.microsoft.com/en-gb/visualstudio/extensibility/how-to-use-rule-based-ui-context-for-visual-studio-extensions

EnableJustMyCode would only be enabled when JustMyCode is disabled. DisableJustMyCode would only be enabled when JustMyCode is enabled. You could give them appropriate icons and tooltips so you can see the state of JustMyCode without auto-loading a package.

Does that make sense?

jnm2 commented 6 years ago

Sure, that's a nice workaround. I'm happy so long as I can see the state before I start debugging.

To play devil's advocate, what if we minimize the startup time of the package so that autoload to set the toggled state is fine? The settings query can't take more than what, a few milliseconds?

jnm2 commented 6 years ago

(I'd still want to be able to bind my keyboard shortcut to toggle, too.)

jcansdale commented 6 years ago

I dare say if you convert it to be an AsyncPackage and used the following, it wouldn't hurt too much. 😉

[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_string, PackageAutoLoadFlags.BackgroundLoad)]
jnm2 commented 6 years ago

Done: https://github.com/tunnelvisionlabs/JustMyCodeToggle/pull/15