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,10 +1064,21 @@ void GitPlusPlusView::onProjectChanged()
void GitPlusPlusView::updateStatus() void GitPlusPlusView::updateStatus()
{ {
m_gitDir = projectBaseDir(); QString newDir = projectBaseDir();
if (m_gitDir.isEmpty()) { if (newDir != m_gitDir) {
setMessage(QStringLiteral("No project directory found"), true); m_gitDir = newDir;
return; detectWorkspace();
if (m_gitDir.isEmpty()) {
setMessage(QStringLiteral("No project directory found"), true);
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),