-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make hot reload a standard request #398
Comments
Searching for "hot reload" in the VS Code repo suggests there are other frameworks that support this (besides Dart/Flutter). Having it as a first-class feature would make it easier to get into other editors (it's less likely this will happen if it's language-specific). Additionally, there are unresolved issues about breakpoints and source modifications in microsoft/vscode#175872. The DA is not given enough information to correctly handle changing breakpoints in unsaved files. By having the editor understand when hot-reload occurs, it can better tell whether the lines it's tracking for breakpoints are valid for the code that's currently loaded, or whether stale code is running (in which case re-sending the full set of breakpoints for a file might mess things up). |
Even if other runtimes support this, I wonder whether they would agree on the exact semantics enough for it to make sense to be driven by the editor. I'd probably prefer to fix the issues with breakpoints and modified source files to enable debuggers to implement it however they need to for their runtime. |
One additional issue with being completely custom, is that the UI requires completely custom work in the editor. There's no way for DAP to say "I have this custom command, show it in the command palette and this button on the debug toolbar" so it requires a language-specific plugin in the editor. While it would be nice to allow a DA to provide this, because the UI differs between DAP clients it would be hard to define "show this button in the debug toolbar next to the restart button" for VS Code in a way that is generic for other editors. (but, I agree it would be good to fix the breakpoint issues in any case 🙂) |
The way the Java debug adapter works is that it tells the DAP Client "The source has changed, issue the following request to hot-reload". This affords the client the ability to ask the user if they wish to reload: If I recall correctly, the Dart approach is that the DAP Client is expected to somehow "just know" when to send this request? I believe some vimspector users have configured up a way to do this on save: https://github.com/puremourning/vimspector/wiki/Additional-Language-Support#hot-reload My response is basically this: puremourning/vimspector#619 (comment) |
Presumably this involves custom events and custom code in the editor?
The user can explicitly trigger Hot Reload by clicking a debug toolbar button or triggering the command from the command palette. Additionally, the Dart extension provides a setting that lets you trigger it automatically on-save. It seems like both Java and DAP have their own non-standard ways of doing this, which is exactly the reason for this issue. |
Yes, indeed it does. So I fully support having a DAP-blessed protocol for this. Just raising here that there are already 2 different approaches that I am aware of.
Right
Completely agree! |
Ah, gotcha! I thought you were suggesting Dart could do what Java was doing, but I understand now. Sorry for the noise :-) |
I don't especially have a preference between the two approaches; I happened to have implemented the java one in vimspector, as it doesn't require any additional UI or teaching users that the feature exists, but it can be a bit annoying if it keeps popping up... |
Within the Dart extension, we use a custom request to ask our running application to update source code files that have changed (see https://github.com/Dart-Code/Dart-Code/blob/master/src/extension/dart/hot_reload_save_handler.ts#L116). We’re wondering if this could be made into a standard event type, e.g.:
The text was updated successfully, but these errors were encountered: