From 3bbf39c67e3108b12cc4eac689050bc5d8d71d12 Mon Sep 17 00:00:00 2001 From: Karboggy Date: Thu, 24 Jul 2025 10:41:57 +0200 Subject: [PATCH] core/reloader: fix file watcher compatibility with vscode --- src/core/generation.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/generation.cpp b/src/core/generation.cpp index 90a29395..54a1b869 100644 --- a/src/core/generation.cpp +++ b/src/core/generation.cpp @@ -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(); } }