Fix issue where dropdown buttons for launching project host pointed to stale projects #2930
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.
Summary of the pull request
This change fixes a bug in scenarios where, when a user has multiple project hosts installed (Visual Studio Code and Visual Studio Code Insiders in the case of our implementation), the launch buttons would not open the most-recently-generated project and instead always attempt to open the first one.
References and relevant issues
#2917
Detailed description of the pull request / Additional comments
If an extension supports multiple project hosts, Quickstart Playground shows a DropdownButton for allowing the user to choose which of those hosts they would like to use for launching their generated project. We noticed that if a user happens to have multiple project hosts installed, then on the second and onward generation attempt in the same session, the launch buttons would not open the most recently generated project. Rather, they would attempt to open the very first project (which would have been cleaned up by that point).
There is code that runs in a property changed handler for associating the entries in the dropdown with specific project host objects. It's triggered by a boolean observable property that controls the visibility on the dropdown button. This code doesn't get invoked on the second generation attempt because it was already set to true from the first attempt. So, the entries in the list never get refreshed. The fix is to ensure that in the command for generating the project, we reset that property first. We can't change just that property on its own because otherwise there would be a gap in the UI from the button being hidden, so we ensure that the single-host button (which is the default) is visible (it won't be enabled though). After the generation completes, the dropdown button will be restored, enabled, and point to the right projects.
Validation steps performed
I verified that on a system with multiple project hosts installed, the user can run multiple sequential project generation attempts and that the launch buttons will correctly invoke the latest-generated project each time.
PR checklist