Skip to content
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

Filesystem watchers for .dart files. #2074

Closed
gskinner opened this issue Oct 27, 2019 · 3 comments · Fixed by #2103
Closed

Filesystem watchers for .dart files. #2074

gskinner opened this issue Oct 27, 2019 · 3 comments · Fixed by #2103
Labels
in flutter Relates to running Flutter apps is discussion / feedback
Milestone

Comments

@gskinner
Copy link

I'm working on a tool that modifies .dart files in a Flutter project. It is a helper tool - VS Code would still be the primary IDE.

Right now, changes to files made by the tool are reflected in VSC, but the change does not trigger a hot-reload. This means that after making edits in the other tool, I have to hit save on a file in VSC in order to trigger the hot-reload.

Ideally, I could open a Flutter project in VS Code, start a debug session, swap over to another tool and make updates to files there, and hot-reload would trigger without having to swap back to VSC.

@DanTup DanTup added this to the v3.7.0 milestone Oct 30, 2019
@DanTup DanTup added in flutter Relates to running Flutter apps is enhancement labels Oct 30, 2019
@DanTup
Copy link
Member

DanTup commented Oct 30, 2019

It wouldn't be difficult to change this - however I'm a little worried about it re-introducing issues like #1427. VS Code has an option for auto-saving and when we use to hot-reload on every one of them, it was really frustrating. So we added a long delay so if the user didn't explicitly press save, we could add a huge debounce delay.

Doing that here would mean you'd have to wait some long period before the hot reload was triggered.

I wonder if there's a better way you could do this from the tool (for ex. if you get the pid of the process - for example by using the --pid-file switch) you could send a SIGUSR1 signal:

    --pid-file          Specify a file to write the process id to. You can send SIGUSR1 to trigger a hot reload and SIGUSR2 to
                        trigger a hot restart.

DanTup added a commit that referenced this issue Nov 14, 2019
This allows reloading automatically when external tools (or Git!) modify files.

Fixes #2074.
DanTup added a commit that referenced this issue Nov 14, 2019
This allows reloading automatically when external tools (or Git!) modify files.

Fixes #2074.
@DanTup
Copy link
Member

DanTup commented Nov 14, 2019

I've added a new setting dart.previewHotReloadOnSaveWatcher which will switch to using a fs watcher for hot reload. It still applies a 200ms debounce to try to avoid firing too much (this means if you're writing lots of files, it'll only fire after there has been a gap of 200ms between any events).

There's a build here if you'd like to try it out:

https://github.com/Dart-Code/Dart-Code/releases/tag/v3.7.0-alpha.1

@gskinner
Copy link
Author

Awesome. Thanks @DanTup - I'll give that a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in flutter Relates to running Flutter apps is discussion / feedback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants