You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great if the last selected device is remembered. Currently, you have to select the device every time after launching VS Code. It's annoying when you don't think about it after pressing F5 (run debug). In my case it always switches back to Windows desktop. But I want Chrome web.
Is this something you'd prefer was per-project, or global? Eg. if you select Chrome in one project and then start another one, would you expect it to also default to Chrome? (the flipside, is if you change that one project to Windows, it would change for the other one too).
Update: Selecting an Android emulator starts the emulator without starting debugging. This might be annoying. Maybe we need to change something here or ask before auto start.
I think we would only auto-select devices. Unstarted emulators are not devices, but once started they will appear as devices (you can see the difference here by running flutter devices and flutter emulators.. an unstarted emulator only appears in the latter but a running emulator appears in both).
So, we'd never auto-start an emulator, but if your preferred device was an emulator, when after you manually start it (or if it's already running) it would be selected.
I was thinking we could add a setting (dart.flutterPreferredDevice?) that you could set in User or Workspace settings, and if this setting was enabled we'd just update/create that setting for you at both levels. However, many users check in workspace settings files so I'm not sure if that's a good place to put it.
So instead, now I'm thinking we should store it somewhere else (extension context - although this is unfortunately invisible to the user) per-project so it just seems to remember the last device you used. We could optionally add a "preferred device" setting that is always user-configured and takes precedence if required. If that seems worthwhile, we can file a new issue and do that separately.
It occurs to me that this is slightly complicated by our auto-selection of mobile devices. Right now, if you connect a mobile device, we will automatically switch to it because we assume you connected it to start using.
We can't really tell if you just connected a mobile device, or if it was connected when you opened VS Code, and it just took Flutter a short while to discover (since it searches for devices somewhat asynchronously). That means if we select a users preferred device and then a mobile device appears, we may switch to that. Perhaps we could skip that if the current selected device happens to be the previously-selected device (I think that's fairly understandable).
I might try this out and see how it feels in a few cases.
I've done the above and it seems to work well in my testing. I'm going to ship this on by default, but it can be opted-out with the dart.flutterRememberSelectedDevice setting. I will likely publish a new pre-release build before the end of the week if you want to try this out before it ships to stable. You can switch to pre-release versions using the button here:
Pre-release versions have a date in the format YYYYMMDD in the last part of the version number (the current version is 3.57.20230104, release on 04 Jan 2023) so one with a newer date than today will include it.
I'd been holding off doing the release because I was trying to land #4337 first, but it's held up a little on some Flutter changes so I'll likely publish a pre-release tomorrow that includes this. I'll ping here when I have as a reminder if you'd like to try it out. Thanks!
v3.57.20230119 has been published and includes this change. Please let me know if it works as you'd expect (flutterRememberSelectedDevice is enabled by default, so you shouldn't need to do anything). Thanks!
Glad it's useful! If anything else is frustrating, please do file issues and don't suffer in silence! While I can't promise to address all frustrations quickly, sometimes there are simple fixes to things that have frustrated people for some time that I wasn't aware of (often because my testing is often quite contrived, and I don't work on any significant Flutter applications).
Activity
DanTup commentedon Jan 9, 2023
Is this something you'd prefer was per-project, or global? Eg. if you select Chrome in one project and then start another one, would you expect it to also default to Chrome? (the flipside, is if you change that one project to Windows, it would change for the other one too).
DanTup commentedon Jan 16, 2023
I think we would only auto-select devices. Unstarted emulators are not devices, but once started they will appear as devices (you can see the difference here by running
flutter devicesandflutter emulators.. an unstarted emulator only appears in the latter but a running emulator appears in both).So, we'd never auto-start an emulator, but if your preferred device was an emulator, when after you manually start it (or if it's already running) it would be selected.
I was thinking we could add a setting (
dart.flutterPreferredDevice?) that you could set in User or Workspace settings, and if this setting was enabled we'd just update/create that setting for you at both levels. However, many users check in workspace settings files so I'm not sure if that's a good place to put it.So instead, now I'm thinking we should store it somewhere else (extension context - although this is unfortunately invisible to the user) per-project so it just seems to remember the last device you used. We could optionally add a "preferred device" setting that is always user-configured and takes precedence if required. If that seems worthwhile, we can file a new issue and do that separately.
DanTup commentedon Jan 16, 2023
It occurs to me that this is slightly complicated by our auto-selection of mobile devices. Right now, if you connect a mobile device, we will automatically switch to it because we assume you connected it to start using.
We can't really tell if you just connected a mobile device, or if it was connected when you opened VS Code, and it just took Flutter a short while to discover (since it searches for devices somewhat asynchronously). That means if we select a users preferred device and then a mobile device appears, we may switch to that. Perhaps we could skip that if the current selected device happens to be the previously-selected device (I think that's fairly understandable).
I might try this out and see how it feels in a few cases.
DanTup commentedon Jan 16, 2023
I've done the above and it seems to work well in my testing. I'm going to ship this on by default, but it can be opted-out with the
dart.flutterRememberSelectedDevicesetting. I will likely publish a new pre-release build before the end of the week if you want to try this out before it ships to stable. You can switch to pre-release versions using the button here:DanTup commentedon Jan 18, 2023
Pre-release versions have a date in the format YYYYMMDD in the last part of the version number (the current version is 3.57.20230104, release on 04 Jan 2023) so one with a newer date than today will include it.
I'd been holding off doing the release because I was trying to land #4337 first, but it's held up a little on some Flutter changes so I'll likely publish a pre-release tomorrow that includes this. I'll ping here when I have as a reminder if you'd like to try it out. Thanks!
DanTup commentedon Jan 19, 2023
v3.57.20230119 has been published and includes this change. Please let me know if it works as you'd expect (
flutterRememberSelectedDeviceis enabled by default, so you shouldn't need to do anything). Thanks!DanTup commentedon Jan 23, 2023
Great, thanks for testing!
jonmountjoy commentedon Jan 27, 2023
Thank you so much for this - it was incredibly frustrating. 👏
DanTup commentedon Jan 27, 2023
Glad it's useful! If anything else is frustrating, please do file issues and don't suffer in silence! While I can't promise to address all frustrations quickly, sometimes there are simple fixes to things that have frustrated people for some time that I wasn't aware of (often because my testing is often quite contrived, and I don't work on any significant Flutter applications).
Thanks!
Add a new setting (default: true) to remember selected devices in a F…