Skip to content

Commit cd2a520

Browse files
committed
Only select supported devices when the current device is disconnected
Fixes #1867.
1 parent eece715 commit cd2a520

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎src/shared/vscode/device_manager.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,19 @@ export class FlutterDeviceManager implements vs.Disposable {
5555
}
5656
}
5757

58-
public deviceRemoved(dev: f.Device) {
58+
public async deviceRemoved(dev: f.Device) {
5959
this.devices = this.devices.filter((d) => d.id !== dev.id);
6060
if (this.currentDevice && this.currentDevice.id === dev.id) {
61-
this.currentDevice = this.devices.length === 0 ? undefined : this.devices[this.devices.length - 1];
61+
this.currentDevice = undefined;
62+
63+
// Try to select the next-best device
64+
if (this.devices.length) {
65+
const supportedPlatforms = await this.getSupportedPlatformsForWorkspace();
66+
const supportedDevices = this.devices.filter((d) => this.isSupported(supportedPlatforms, d));
67+
if (supportedDevices && supportedDevices.length)
68+
this.currentDevice = supportedDevices[0];
69+
}
70+
6271
this.updateStatusBar();
6372
}
6473
}

0 commit comments

Comments
 (0)