lsp-dart
lsp-dart copied to clipboard
dap-debug in Flutter project should only list running devices to chose from
Describe the bug
When I execute dap-debug I get asked for a debug template and then for a device to run the app on.
It always lists my real device, the one which I actually want to use
and some emulator that is defined somewhere (I guess I run flutter emulators --create at some point).
Note Before logging the bug please make sure that the issue is reproducible with latest melpa packages.
To Reproduce {populate}
Expected behavior It should only list running emulators and connected devices, like these shown by
flutter devices
or
adb devices -l
Ideally, if there is only one device, it should just use it and not ask at all. (it might even do that already, but I can't tell)
Screenshots If applicable, add screenshots to help explain your problem.
Version
[LSP Dart] 1.17.6 (package: 20200510.2055) at 2020.09.24 @ Emacs 28.0.50
[Dart SDK] Dart SDK version: 2.10.0-110.3.beta (beta) (Tue Sep 15 14:39:26 2020 +0200) on "linux_x64"
We can improve to use the only available emulator/device when there is only one. But I didn't understand the original issue, is lsp-dart showing emulator/devices that are not connected?
Yes, it shows an emulator that was created with flutter emulators some time ago, but the emulator is not running.
I see, this should be a bug where lsp-dart is not clearing the emulators variable, I'll try to take a look soon :)
@zoechi, this behaviour is something that I saw on VScode and maybe should keep as it is(maybe add some customizable variable) where lsp-dart starts the flutter process and listen to what devices and emulators are available, if user chooses an emulator, lsp-dart will automatically start that emulator and debug the code through it.
I see some possible solutions:
- Create a variable
lsp-dart-dap-only-listen-running-deviceswith default tonil - Add some
lsp-dart-delete-device/emulatorcommand
I'd prefer the former. I want to create/delete/modify emulator specifications using the flutter emulators command (outside of Emacs) for various use cases but do not want to be bothered with them every time I run or debug.
Perhaps a flutter emulators run command might be helpful for scripting to ensure it runs before run/debug starts, but no priority for me.
A way to pass one or more device names to the run/debug command to skip the device selection alltogether would be a way to fix the issue. Flutter run/debug can execute on multiple devices simultaneously which is currently not covered because only one can be selected.
I found https://github.com/flutter/flutter/issues/30724#issuecomment-480985603 which looks related. It seems lsp-dart always uses getEmulators, not only when no available devices were found.
I see, so do you think lsp-dart should only try to get emulators if a real device is not connected?
Yes. Only available devices should be listed - like returned from "flutter devices"