Skip to content

Commit 3bbf39c

Browse files
karboggyoutfoxxed
authored andcommitted
core/reloader: fix file watcher compatibility with vscode
1 parent f90bef2 commit 3bbf39c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/core/generation.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ 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+
auto fileInfo = QFileInfo(name);
228+
if (fileInfo.isFile() && fileInfo.size() == 0) return;
229+
225230
emit this->filesChanged();
226231
}
227232
}

0 commit comments

Comments
 (0)