lsp-dart icon indicating copy to clipboard operation
lsp-dart copied to clipboard

dap-debug in Flutter project should only list running devices to chose from

Open zoechi opened this issue 5 years ago • 8 comments

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"

zoechi avatar Sep 24 '20 07:09 zoechi

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?

ericdallo avatar Sep 24 '20 12:09 ericdallo

Yes, it shows an emulator that was created with flutter emulators some time ago, but the emulator is not running.

zoechi avatar Sep 24 '20 18:09 zoechi

I see, this should be a bug where lsp-dart is not clearing the emulators variable, I'll try to take a look soon :)

ericdallo avatar Sep 24 '20 19:09 ericdallo

@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-devices with default to nil
  • Add some lsp-dart-delete-device/emulator command

ericdallo avatar Sep 27 '20 15:09 ericdallo

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.

zoechi avatar Sep 27 '20 20:09 zoechi

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.

zoechi avatar Oct 01 '20 13:10 zoechi

I see, so do you think lsp-dart should only try to get emulators if a real device is not connected?

ericdallo avatar Oct 01 '20 13:10 ericdallo

Yes. Only available devices should be listed - like returned from "flutter devices"

zoechi avatar Oct 01 '20 18:10 zoechi