Skip to content

Commit 5a39e44

Browse files
committed
core/reloader: fix file watcher compatibility with vscode
1 parent db77c71 commit 5a39e44

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/core/generation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ void EngineGeneration::onFileChanged(const QString& name) {
222222
if (!this->watcher->files().contains(name)) {
223223
this->deletedWatchedFiles.push_back(name);
224224
} else {
225+
// some editors (e.g vscode) perform file saving in two steps: truncate + write
226+
// ignore the first event (truncate) with size 0 to prevent incorrect live reloading
227+
if (QFileInfo(name).size() == 0) {
228+
return;
229+
}
230+
225231
emit this->filesChanged();
226232
}
227233
}

0 commit comments

Comments
 (0)