core/reloader: fix file watcher compatibility with vscode

This commit is contained in:
Karboggy 2025-07-24 10:41:57 +02:00 committed by outfoxxed
parent f90bef2d99
commit 3bbf39c67e
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E

View file

@ -222,6 +222,11 @@ void EngineGeneration::onFileChanged(const QString& name) {
if (!this->watcher->files().contains(name)) {
this->deletedWatchedFiles.push_back(name);
} else {
// some editors (e.g vscode) perform file saving in two steps: truncate + write
// ignore the first event (truncate) with size 0 to prevent incorrect live reloading
auto fileInfo = QFileInfo(name);
if (fileInfo.isFile() && fileInfo.size() == 0) return;
emit this->filesChanged();
}
}