From fe4c6187800e046e298bdd9f78bcb0e3ae81bd6c Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Wed, 22 Jul 2026 16:22:14 +0200 Subject: [PATCH] Fix .kateproject generation: per-repo, not workspace-level Kate project plugin needs .kateproject in each repo subdir for project switching to work. A workspace-level .kateproject makes Kate treat the whole workspace as one project, breaking repo switching. --- gitplusplus.cpp | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/gitplusplus.cpp b/gitplusplus.cpp index 891ab0f..b0ecd24 100644 --- a/gitplusplus.cpp +++ b/gitplusplus.cpp @@ -2322,14 +2322,16 @@ void GitPlusPlusView::detectWorkspace() ws.sync(); } - // Auto-generate .kateproject if missing - QString kateProjectFile = m_workspaceDir + QStringLiteral("/.kateproject"); - if (!QFileInfo::exists(kateProjectFile)) { - QFile kp(kateProjectFile); - if (kp.open(QIODevice::WriteOnly | QIODevice::Text)) { - QString wsName = QFileInfo(m_workspaceDir).fileName(); - kp.write("{\n \"name\": \"" + wsName.toUtf8() + "\",\n \"files\": [ { \"git\": true } ]\n}\n"); - kp.close(); + // Auto-generate .kateproject in each repo subdir that lacks one + for (const auto &repoPath : qAsConst(m_workspaceRepos)) { + QString kateProjectFile = repoPath + QStringLiteral("/.kateproject"); + if (!QFileInfo::exists(kateProjectFile)) { + QFile kp(kateProjectFile); + if (kp.open(QIODevice::WriteOnly | QIODevice::Text)) { + QString repoName = QFileInfo(repoPath).fileName(); + kp.write("{\n \"name\": \"" + repoName.toUtf8() + "\",\n \"files\": [ { \"git\": true } ]\n}\n"); + kp.close(); + } } } @@ -2556,11 +2558,17 @@ void GitPlusPlusView::createWorkspace() } } - // 6. Write .kateproject in new workspace - QFile kateProject(newWsPath + QStringLiteral("/.kateproject")); - if (kateProject.open(QIODevice::WriteOnly | QIODevice::Text)) { - kateProject.write("{\n \"name\": \"" + name.toUtf8() + "\",\n \"files\": [ { \"git\": true } ]\n}\n"); - kateProject.close(); + // 6. Write .kateproject in each repo subdir + for (const auto &repoName : sourceRepos) { + QString targetRepoPath = newWsPath + QLatin1Char('/') + repoName; + QString kpFile = targetRepoPath + QStringLiteral("/.kateproject"); + if (QFileInfo::exists(targetRepoPath) && !QFileInfo::exists(kpFile)) { + QFile kp(kpFile); + if (kp.open(QIODevice::WriteOnly | QIODevice::Text)) { + kp.write("{\n \"name\": \"" + repoName.toUtf8() + "\",\n \"files\": [ { \"git\": true } ]\n}\n"); + kp.close(); + } + } } if (failed == 0) {