Detect workspace changes in updateStatus

When projectBaseDir() returns a different path, re-run detectWorkspace()
and setupFileWatcher(). This catches project switches regardless of
which signal triggers the refresh (viewChanged, doc save, timer, etc.).
This commit is contained in:
Levi Neely 2026-07-23 08:58:22 +02:00
parent 1d89a5652d
commit b06d4dbe2f
1 changed files with 15 additions and 4 deletions

View File

@ -1064,11 +1064,22 @@ void GitPlusPlusView::onProjectChanged()
void GitPlusPlusView::updateStatus() void GitPlusPlusView::updateStatus()
{ {
m_gitDir = projectBaseDir(); QString newDir = projectBaseDir();
if (newDir != m_gitDir) {
m_gitDir = newDir;
detectWorkspace();
if (m_gitDir.isEmpty()) { if (m_gitDir.isEmpty()) {
setMessage(QStringLiteral("No project directory found"), true); setMessage(QStringLiteral("No project directory found"), true);
return; return;
} }
setupFileWatcher();
} else {
m_gitDir = newDir;
if (m_gitDir.isEmpty()) {
setMessage(QStringLiteral("No project directory found"), true);
return;
}
}
auto *proc = GitProcess::create(m_gitDir, {QStringLiteral("status"), QStringLiteral("--porcelain=v1")}, this); auto *proc = GitProcess::create(m_gitDir, {QStringLiteral("status"), QStringLiteral("--porcelain=v1")}, this);
connect(proc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), connect(proc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, &GitPlusPlusView::onStatusFinished); this, &GitPlusPlusView::onStatusFinished);