slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.99k stars 568 forks source link

Smart inline debug info in VSCode slint editor #6163

Open NigelBreslaw opened 1 week ago

NigelBreslaw commented 1 week ago
Screenshot 2024-09-16 at 12 41 56

Idea is that in a declarative language the latest value for the bindings are essentially invisible. Making them temp visible inside the editor would be so useful. Also just seeing the latest value is way more useful than a stream of zillions of values flying past in the terminal.

inspired by Console Ninja if you use slint debug() in your code the very latest log would be shown inline in vscode at the end of the line. I was going to try and make a very hacky version by placing a unique ID in the debug message. Parse it out the terminal window and then show the rest of the debug info. But just don't have the time right now.

Maybe a non hack version would get the name of the file and the line number from the LSP?

V 2.0

Screenshot 2024-09-16 at 12 53 22

Then the 'next level' version would be any line that shows a property e.g rotation: atan( dial.y / dial.x) you could click something. Maybe as simple as clicking in the margin with the line numbers and reuse the break point system vscode has to also cause an inline latest value to show. I think Console Ninja has something like this? That way you get the debug, but without modifying any of your code.

tronical commented 1 week ago

I'm not sure how to exactly area'ize this correctly. But I think this could be built in piece:

  1. We change the compiler to pass the location (file name, line, and column) to the run-time library for debug() invocations.
  2. The run-time library makes these available to the lsp.
  3. The lsp - upon retrieval - provides the last received output at the location to the editor as annotation of sorts.
ogoffart commented 1 week ago

We don't have a component for a debugger yet, let alone an issue for it. This really depends on a debugger. Although debug statement are special and could record their position (that would be useful to show the file and line line number also in the debug output), and the preview could hijack the debug call to send it to the LSP as a range for an inlay hint.

tronical commented 1 week ago

We don't have a component for a debugger yet, let alone an issue for it. This really depends on a debugger. Although debug statement are special and could record their position (that would be useful to show the file and line line number also in the debug output), and the preview could hijack the debug call to send it to the LSP as a range for an inlay hint.

That's exactly Nigel's proposal ;)

NigelBreslaw commented 1 week ago

Also if terminal output gained a link to the file and line number that would be great too. Screenshot 2024-09-16 at 13 20 55 Is this standardised as it does this for react apps in the normal VSCODE terminal without a plugin?