File Watcher for Slint Editor#11508
Conversation
and a file watcher to the Slint editor to detect changes in `.slint` files. Note that this will not correctly track resource files at the moment if they are outside of the project directory. We should wait until the remote viewer has implemented this in order to unify it between all of the different file watcher implementations.
cc67f75 to
dcb85c4
Compare
By builtin-live preview, you don't mean the live preview for Rust/C++, i guess. Because there is also a file watcher in interpreter/live_preview.rs. Why didn't you re-use that one? (When I added the one in interpreter/live_preview.rs, i thought we could migrate the viewer to use it, but that never happened) |
I do mean that one. Ah, crap, I hadn't noticed that this one already contains a separate FileWatcher abstraction 🙈 But we shouldn't have a third file watcher in any case 😅 |
|
@ogoffart What do you think of the approach of watching the entire project directory? |
I don't like it. This is what the LSP does: Line 130 in cd89140 And this is the reason why, i suspect, many apps stop working with "too many open file" when vscode is open, (because it would watch the entire monorepo of slint includeing the target directory or at least, too many files) There are other way to detext dependencies on resources. The object_tree::Document::embedded_file_resources could have it if we pass the right flags to the CompilerConfig (EmbedResourcesKind::ListAllResources, I think this was added precisely for this usecase) Also there could be files outside of the project directory (eg, libraries in ~/.cargo/ or somewhere else). Arguably, these shouldn't change. But it can also be hard to find the project root |
The new file watcher is not quite as aggressive, but it still watches the highest folder recursively that contains a loaded file.
Right, that is what the new FileWatcher basically does, it extracts a full list of file paths out of the TypeLoader. So to combine the best of both approaches, we should extract the file watcher into its own module in the interpreter, use the new function from the typeloader to detect the files we need to watch and try to minimize the number of files we watch via notify. (we'll have to do some extensive testing on the file watcher for this). |
Add a file watcher to the Slint editor to detect changes in
.slintfiles.
Note that this will not correctly track resource files at the moment if
they are outside of the project directory.
We should wait until the remote viewer has implemented this in order to
unify it between all of the different file watcher implementations.
@ogoffart I think we should probably migrate the slint-viewer and built-in live
preview over to this as well. Then we can have a single source of truth
for extracting all file paths out of a type loader and watching them.
They currently use the open_imports_callback to detect file changes, but
that won't detect changes on resource files.
Moving it into the interpreter as a file_watcher module is best IMO.