diff --git a/gitplusplus.cpp b/gitplusplus.cpp index cb3843a..273ec96 100644 --- a/gitplusplus.cpp +++ b/gitplusplus.cpp @@ -430,7 +430,7 @@ GitPlusPlusView::GitPlusPlusView(GitPlusPlusPlugin *plugin, KTextEditor::MainWin // Debounce timer for filesystem changes (avoid spamming refreshes) m_fsDebounce.setSingleShot(true); m_fsDebounce.setInterval(500); - connect(&m_fsDebounce, &QTimer::timeout, this, &GitPlusPlusView::updateStatus); + connect(&m_fsDebounce, &QTimer::timeout, this, &GitPlusPlusView::refreshAll); // Initial refresh QMetaObject::invokeMethod(this, &GitPlusPlusView::updateStatus, Qt::QueuedConnection); @@ -544,7 +544,15 @@ void GitPlusPlusView::setupFileWatcher() if (!watchPaths.isEmpty()) { m_watcher->addPaths(watchPaths); - connect(m_watcher, &QFileSystemWatcher::fileChanged, this, [this](const QString &) { + connect(m_watcher, &QFileSystemWatcher::fileChanged, this, [this](const QString &path) { + // Re-add the path: QFileSystemWatcher drops watches when files are + // replaced atomically (git writes a temp file then renames over it) + if (!m_watcher->files().contains(path)) { + QTimer::singleShot(100, this, [this, path]() { + if (QFileInfo::exists(path)) + m_watcher->addPath(path); + }); + } // Debounce: multiple changes can fire rapidly m_fsDebounce.start(); });