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

Is there any way to toggle debug painting?

Open jkaye2012 opened this issue 4 years ago • 7 comments

Hi all,

Thanks for this amazing package. It's an unparalleled development experience, even by Emacs standards.

I was wondering if there is any way to toggle Flutter's debug painting either through lsp or dap?

Thanks!

jkaye2012 avatar Aug 11 '21 13:08 jkaye2012

screenshot will help.

yyoncho avatar Aug 11 '21 14:08 yyoncho

Sorry, screenshot of what? Flutter supports toggling debug painting by pressing "p" in the terminal. I've looked through the docs, and so far as I can tell this is one of the only debugging capabilities that I can't find exposed through either lsp-dart or dap.

To clarify, this isn't something that I think is broken, I'm just wondering if it's supported at all (and if it's not currently, if this would be something worth adding).

jkaye2012 avatar Aug 11 '21 14:08 jkaye2012

@jkaye2012 I use hover (I suggest you take a look, it's awesome) to develop in flutter with lsp-dart, I usually don't use dap with flutter, but answering your question, it's really missing, although we can easily follow the hotReload/hotRestart feature which works and implement that support for the other missing features during dap: https://github.com/emacs-lsp/lsp-dart/blob/master/lsp-dart-dap.el#L340-L346

ericdallo avatar Aug 11 '21 15:08 ericdallo

The dap route is what I was thinking as well. Would be really cool!

jkaye2012 avatar Aug 12 '21 16:08 jkaye2012

I'll try to take a look and maybe add the missing ones in the weeked

ericdallo avatar Aug 12 '21 16:08 ericdallo

If anyone is interested I implemented this for https://github.com/akinsho/flutter-tools.nvim which is the neovim cousin of this project

It involves listening to the dart.serviceExtensionAdded dap event and maintaining a local map of (serviceExtension -> isolateId), and when debugPaint is requested sending a dap request "callService" with a body like :

{
  "method": "ext.flutter.debugPaint",
  "params": {
    "enabled": true,
    "isolateId": "<isolateId for which a serviceExtensionAdded event with extensionRPC = ext.flutter.debugPaint was received >"
  }
}

It's a bug more involved than the simple hotReload / Restart because you have to target the flutter isolate, but it allows for a bunch of other sweet stuff, like override the platform, or slowing animations... The full list of what the VSCode extension can do is here https://github.com/Dart-Code/Dart-Code/blob/677cf32830e0899a0e0371f47f75a668b97f6b9e/src/shared/enums.ts#L22-L36

Sorry I can't provide an implementation, I'm not very good at elisp

Lua implementation is here if needed : https://github.com/akinsho/flutter-tools.nvim/blob/8c88c4cd9ad3f5b72335451744f7c07d374e3fa6/lua/flutter-tools/runners/dap_runner.lua

clement-buchart avatar Nov 24 '21 09:11 clement-buchart

Thank you @clement-buchart that should certainly help with this on lsp-dart :)

ericdallo avatar Nov 24 '21 14:11 ericdallo